Commit graph

1514 commits

Author SHA1 Message Date
joeduffy 08ca40c6c6 Unmap properties on the receive side
This change makes progress on a few things with respect to properly
receiving properties on the engine side, coming from the provider side,
of the RPC boundary.  The issues here are twofold:

    1. Properties need to get unmapped using a JSON-tag-sensitive
       marshaler, so that they are cased properly, etc.  For that, we
       have a new mapper.Unmap function (which is ultra lame -- see
       pulumi/lumi#138).

    2. We have the reverse problem with respect to resource IDs: on
       the send side, we must translate from URNs (which the engine
       knows about) and provider IDs (which the provider knows about);
       similarly, then, on the receive side, we must translate from
       provider IDs back into URNs.

As a result of these getting fixed, we can now properly marshal the
resulting properties back into the resource object during the plan
execution, alongside propagating and memoizing its ID.
2017-06-01 08:39:48 -07:00
joeduffy ae8cefcb20 Print output properties in the CLI
This change skips printing output<T> properties as we perform a
deployment, instead showing the real values inline after the resource
has been created.  (output<T> is still shown during planning, of course.)
2017-06-01 08:37:56 -07:00
joeduffy 87ad371107 Only flow logging to plugins if --logflow
The change to flow logging to plugins is nice, however, it can be
annoying because all writes to stderr are interepreted on the Lumi
side as errors.  After this change, we will only flow if
--logflow is passed, e.g. as in

    $ lumi --logtostderr --logflow -v=9 deploy ...
2017-06-01 08:37:56 -07:00
joeduffy cb2a702596 Redefine AWS provider IDs to be ARNs
This change overhauls our AWS resource provder to use ARNs for all
AWS resource IDs.  We have gone backwards and forwards on whether to
use the name, ID, or ARN for this purpose.  This confusion was largely
driven by the inconsistencies within the AWS APIs themselves: sometimes
a resource's name is the preferred identifier, sometimes its ID,
sometimes its ARN, and there are even cases where it differs based on
context (e.g., nondefault versus default VPC).

Thankfully, ARNs are perfectly consistent, and well-defined, on this
matter.  See http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html.
Although any given API may request an ID or name that isn't part of the
ARN, the ARN is always sufficiently complete and lossless to enable
recovery of the information needed.  And furthermore, even if an API
doesn't want the full ARN, the resource name component of the resource's
ARN is easily parseable and useable in this role.

To facilitate this, I've created a new `arn` package that has a number
of factory and parsing helpers.

Overall, some things are more verbose -- e.g., we must always translate
from ARN space to names and vice versa -- however, using the ARN is
clarifying and guarantees that we always have a way to get the information
we need.  And in general, thanks to the removal of several workarounds in
the code, I think we come out ahead in general code delta-wise.
2017-06-01 08:37:16 -07:00
joeduffy 0a72d5360a Modify provider creates; use get for outs
This change modifies the existing resource provider RPC interface slightly.
Instead of the Create API returning the bag of output properties, we will
rely on the Get API to do so.  As a result, this change takes an initial
whack at implementing Get on all existing AWS resources.  The Get API needs
to return a fully populated structure containing all inputs and outputs.

Believe it or not, this is actually part of pulumi/lumi#90.

This was done because just returning output properties is insufficient.
Any input properties that weren't supplied may have default values, for
example, and it is wholly reasonable to expect Lumi scripts to depend on
those values in addition to output values.

This isn't fully functional in its current form, because doing this
change turned up many other related changes required to enable output
properties.  For instance, at the moment resource properties are defined
in terms of `resource.URN`s, and yet unfortunately the provider side
knows nothing of URNs (instead preferring to deal in `resource.ID`s).
I am going to handle that in a subsequent isolated change, since it will
have far-reaching implications beyond just modifying create and get.
2017-06-01 08:36:43 -07:00
joeduffy 47e242f9a7 Rearrange some deployment logic
This change prepares for integrating more planning and deployment logic
closer to the runtime itself.  For historical reasons, we ended up with these
in the env.go file which really has nothing to do with deployments anymore.
2017-06-01 08:36:43 -07:00
joeduffy 7f98387820 Distinguish between computed and output properties
This change introduces the notion of a computed versus an output
property on resources.  Technically, output is a subset of computed,
however it is a special kind that we want to treat differently during
the evaluation of a deployment plan.  Specifically:

* An output property is any property that is populated by the resource
  provider, not code running in the Lumi type system.  Because these
  values aren't available during planning -- since we have not yet
  performed the deployment operations -- they will be latent values in
  our runtime and generally missing at the time of a plan.  This is no
  problem and we just want to avoid marshaling them in inopportune places.

* A computed property, on the other hand, is a different beast altogehter.
  Although true one of these is missing a value -- by virtue of the fact
  that they too are latent values, bottoming out in some manner on an
  output property -- they will appear in serializable input positions.
  Not only must we treat them differently during the RPC handshake and
  in the resource providers, but we also want to guarantee they are gone
  by the time we perform any CRUD operations on a resource.  They are
  purely a planning-time-only construct.
2017-06-01 08:36:43 -07:00
joeduffy e4462087a5 Add a @lumi.out decorator
This change adds a @lumi.out decorator and modifies LumIDL to emit it on
output properties of resource types.  There still isn't any runtime
awareness, however, this is an isolated change that will facilitate it.
2017-06-01 08:32:12 -07:00
joeduffy ddd63e8788 Permit (and test) complex decorators 2017-06-01 08:32:12 -07:00
joeduffy 7879032e88 Pretty-print attributes in lumi pack info command
This change pretty-prints attribute metadata in `lumi pack info`.
For example:

    package "basic/decorators" {
        dependencies []
        module "index" {
            exports []
            method ".main": ()
            class "TestDecorators" [@basic/decorators:index:classDecorate] {
                property "a" [public, @basic/decorators:index:propertyDecorate]: string
                method "m1" [public, @basic/decorators:index:methodDecorate]: (): string
            }
        }
    }

It also includes support for printing property getters/setters:

    property "p1" [public]: string {
        method "get" [public, @basic/decorators:index:methodDecorate]: (): string
        method "set" [public]: (v: string)
    }
2017-06-01 08:32:12 -07:00
joeduffy acdab34d7a Support decorators in more places
We need to smuggle metadata from the resource IDL all the way through
to the runtime, so that it knows which things are output properties.  In
order to do this, we'll leverage decorators and the support for serializing
them as attributes.  This change adds support for the various kinds
(class, property, method, and parameter), in addition to test cases.
2017-06-01 08:32:12 -07:00
joeduffy 706acb5fd8 Tolerate latent values in more places 2017-06-01 08:32:12 -07:00
joeduffy d79c41f620 Initial support for output properties (1 of 3)
This change includes approximately 1/3rd of the change necessary
to support output properties, as per pulumi/lumi#90.

In short, the runtime now has a new hidden type, Latent<T>, which
represents a "speculative" value, whose eventual type will be T,
that we can use during evaluation in various ways.  Namely,
operations against Latent<T>s generally produce new Latent<U>s.

During planning, any Latent<T>s that end up in resource properties
are transformed into "unknown" property values.  An unknown property
value is legal only during planning-time activities, such as Check,
Name, and InspectChange.  As a result, those RPC interfaces have
been updated to include lookaside maps indicating which properties
have unknown values.  My intent is to add some helper functions to
make dealing with this circumstance more correct-by-construction.

For now, using an unresolved Latent<T> in a conditional will lead
to an error.  See pulumi/lumi#67.  Speculating beyond these -- by
supporting iterative planning and application -- is something we
want to support eventually, but it makes sense to do that as an
additive change beyond this initial support.  That is a missing 1/3.

Finally, the other missing 1/3rd which will happen much sooner
than the rest is restructuing plan application so that it will
correctly observe resolution of Latent<T> values.  Right now, the
evaluation happens in one single pass, prior to the application, and
so Latent<T>s never actually get witnessed in a resolved state.
2017-06-01 08:32:12 -07:00
Luke Hoban 9531483e19 Add tests for AWS DynamoDB Table provider 2017-05-31 17:06:16 -07:00
Luke Hoban 01af21a1e4 Support for multiple methods on route in aws.serverless.API
Also adds length property to String objects and a toLowerCase method to the String prototype.
2017-05-31 11:45:02 -07:00
Luke Hoban 715a26bfba Introduce aws.serverless package with API and Function
This new package is similar to the AWS Serverless Application Model, offering
higher-level interfaces to manage serverless resources. This will be a candidate
for moving into its own package in the future.

The FunctionX class has been moved into this module, and a new API class has
been added

The API class manages a collection of an API Gateway RestAPI, Stage and Deployment,
based on a collection of routes linked to Functions.  On changes to the API specification,
it updates the RestAPI, replaces the Deployment and updates the Stage to point to
the updated Deployment.

This change also reorganizes some of the intrinsics.
2017-05-31 11:45:02 -07:00
Luke Hoban 1ba42954f4 WIP on AWS ApiGateway resource providers
Adds support for RestApi, Deployment and Stage resources.

Resolves #180.
2017-05-31 11:42:58 -07:00
Luke Hoban 99499792b3 Serialize lambda environment variables in stable order
When serializing a closure, we serialize the lambda environment into the
aws.lambda.Function Environment property.  We need to serialize the lambda
environment in a stable order to ensure that we don't cause Lumi to require
updates to the aws.lambda.Function resource.
2017-05-31 11:40:22 -07:00
joeduffy ab6e2466c7 Flow logging information to plugins
This change flows --logtostderr and -v=x settings to any dynamically
loaded plugins so that running Lumi's command line with these flags
will also result in the plugins logging at the requested levels.  I've
found this handy for debugging purposes.
2017-05-30 10:19:33 -07:00
Luke Hoban 75c25e0ce6 Add documentation for HashSets APIs 2017-05-29 10:11:47 -07:00
Luke Hoban 8bbf48bf87 Support for AWS DynamoDB Table GlobalSecondaryIndexes
Adds support for global secondary indexes on DynamoDB Tables.

Also adds a HashSet API to the AWS provider library.  This handles part of #178,
providing a standard way for AWS provider implementations to compute set-based
diffs. This new API is used in both aws.dynamodb.Table and aws.elasticbeanstalk.Environment
currently.
2017-05-26 14:54:35 -07:00
Luke Hoban 7f8b1e59c1 Support for lambdas (#158)
Resolves #137.

This is an initial pass for supporting JavaScript lambda syntax for defining an AWS Lambda Function.

A higher level API for defining AWS Lambda Function objects `aws.lambda.FunctionX` is added which accepts a Lumi lambda as an argument, and uses that lambda to generate the AWS Lambda Function code package.

LumiJS lambdas are serialized as the JavaScript text of the lambda body, along with a serialized version of the environment that is deserialized at runtime and used as the context for the body of the lambda.

Remaining work to further improve support for lambdas is being tracked in #173, #174, #175, and #177.
2017-05-25 16:55:14 -07:00
Luke Hoban 6015c96fda Add jsonStringify intrinsic
This will eventually be used as the implementation of JSON.stringify in LumiJS.
2017-05-25 12:19:58 -07:00
Luke Hoban b8d978b22c Move Intrinsic into eval/rt package
Unifies the notion of BuiltinFunctions with the existing Intrinsic.

Intrinsic is now only a wrapper type, used to indicate the need to lookup the symbol in the
eval pacakges table of registered intrinsics.  It does not carry the invoker function used
to eval the intrinsic.
2017-05-25 12:06:13 -07:00
Luke Hoban a625117e72 Add a length property to Array objects
Also adds a `lumi.runtime.printf` function for debugging Lumi scripts and fixes a couple issues with getter/setter references.
2017-05-25 12:06:13 -07:00
joeduffy 28c9c80b74 Enable Slack notifications for Travis CI 2017-05-25 07:36:17 -07:00
joeduffy 9f9e885c87 Fence some CONTRIBUTING.md code correctly 2017-05-24 18:10:30 -07:00
joeduffy dfee663ccc Create a CONTRIBUTING.md file
This change creates a CONTRIBUTING.md file, closing pulumi/lumi#160.
2017-05-24 18:06:59 -07:00
joeduffy e9cc0acb05 Update instructions for Govet 2017-05-24 13:25:28 -07:00
Joe Duffy dd706ca4e4 Merge pull request #163 from pulumi/lumi-162-cicd
Enable Travis CI/CD
2017-05-24 13:23:20 -07:00
joeduffy dba4e2258c Add a build badge 2017-05-24 12:50:29 -07:00
joeduffy e39d1c5ada Skip -printf checks in Govet
Due to https://github.com/golang/go/issues/12294, our Travis jobs are
failing with

    pkg/compiler/binder/stmtexpr.go:160: no formatting directive in Errorf call

etc, etc.  Perplexingly, this is supposedly fixed as of Go 1.7.5, and we are
running Go 1.8.2 in Travis.  However, vet is a separate binary tool, so it seems
either (1) Go's Linux distro doesn't contain the right version or (2) Travis's
image doesn't contain the right version.  I have to imagine (2) is more likely,
except that I can't actually look at the machine (and go vet doesn't have a version)!

For now, we will just skip the -printf checks.
2017-05-24 12:50:29 -07:00
joeduffy 9aa1d8147b Remove master from the list of valid Go versions 2017-05-24 12:50:28 -07:00
joeduffy a1cf0c2a6c Update to Go 1.8.2 2017-05-24 12:50:28 -07:00
joeduffy 8f1fa79230 Rewrite eval test to be self-contained
The eval test in its current form depends on the Lumi standard library
as an external dependency.  This means that, in order to run the test,
you must first install the standard library.  Not only is this poor
practice, it is also interfering with our ability to get our new CI/CD
system up and running.  This change fixes all of that by mocking the one
standard library runtime function that we need in order to hook the intrinsic.
2017-05-24 12:50:28 -07:00
joeduffy d92ccc9cb5 Add -v flag to godep restore
This change adds the -v flag so that verbose output is emitted in the
CI/CD logs.  Since restore can take a little while, this at least lets
you monitor what it's doing and how long what it's doing is taking...
2017-05-24 12:50:28 -07:00
joeduffy efdfa42527 Manually install Godep in pre-install 2017-05-24 12:50:28 -07:00
joeduffy c18ae86cc8 Manually godep restore during install 2017-05-24 12:50:28 -07:00
joeduffy 88ea603551 Switch from Glide to Godep for dependency management
There isn't a pre-canned Glide distribution for amd64 linux, and the
integration with Glide and Travis isn't nearly as swanky as with Godep
(which essentially works out of the box).  Furthermore, Godep has caught
up with Go's vendoring changes since last time I looked, which was the
primary reason I ended up going with Glide in the first place.
2017-05-24 12:50:28 -07:00
joeduffy 9ed22eba6f Prep the $GOPATH/bin directory
The Glide installation script requires that the $GOPATH/bin directory
already exists, but because it is pre-install, it doesn't.  Make it so.
2017-05-24 12:50:28 -07:00
joeduffy f93f8f0510 Add a basic Travis CI/CD file
This is the beginning of pulumi/lumi#162.
2017-05-24 12:50:28 -07:00
Luke Hoban 5768a372d1 Support updates which remove Environment on AWS Lambda Function
If the Environment is removed, we must pass an empty map of variables to `UpdateFunctionConfiguration`.
2017-05-23 21:45:58 -07:00
Luke Hoban 1bab33064a Support for AWS Lambda Function Environment property 2017-05-23 17:35:51 -07:00
Luke Hoban ced90154e0 Add support for AWS IAM Managed Policies
We now support the `ManagedPolicyARNs` property on `aws.iam.Role`, enabling pre-defined policies to be attaced to an IAM role as part of it's definition.

To make it easier to discover and work with AWS managed policies, constants for all currently defined AWS managed policy ARNs are provided in the IAM module.

Inline policies are still not yet supported.
2017-05-23 13:57:51 -07:00
Joe Duffy f541853226 Merge pull request #157 from pulumi/intrinsic-fix
Fix a few intrinsics bugs
2017-05-23 08:05:19 -07:00
joeduffy 2bbc4739bd Add some intrinsics tests
This change adds some machinery to make it easier to write evaluator tests,
and also implements some tests for the lumi:runtime/dynamic:isFunction intrinsic.
2017-05-23 08:03:14 -07:00
Luke Hoban 35a41f9e4a Support Update on IAM Role and Lambda Function 2017-05-22 22:57:55 -07:00
joeduffy bad62854a9 Fix a few intrinsics bugs
During various refactorings pertaining to dynamic vs static invoke, the
intrinsics machinery broke in a few ways:

* MaybeIntrinsic needs to happen elsewhere.  Rather than doing it at binding
  time, we can do it when populating the properties in the first place,
  reusing the same property symbol from one access to the next.

* Last week, I refactored the intrinsics module to also have a dynamic sub-
  module.  The tokens in the Intrinsics map needed to also get updated.

* As a result of the tokens now containing member parts, we can't use
  tokens.Token.Name, since it is assumed to be a simple name; instead, we
  need to convert to tokens.ModuleMember, and then fetch Name.  To be honest,
  this is probably worth revisiting, since I think most people would expect
  Name to just work regardless of the Token kind.  The assert that it be
  Simple might be a little overly aggressive...

This checkin fixes these issues.  I'm not pushing to master just yet,
however, until there are some solid tests in here to prevent future breakage.
2017-05-22 16:16:53 -07:00
joeduffy ecd9a953d0 Remove @code annotation on asset.Code
This is triggering the need for all downstream consumers of the Lumi
library to enable experimental decorators support.  Given that it's not
even clear where we'll land on this (pending pulumi/lumi#137), and in
fact are actively revisiting the relationship between functions and
assets, I'm removing this annotation.
2017-05-22 14:14:21 -07:00
joeduffy 6e0d388c90 Make argument objects optional when no required properties
If a resource has no required properties, there's no need for an
argument object.  (In the extreme case, perhaps the resource has
*no* properties.)  This is a minor usability thing, but it's far
nicer to write code like

    let buck = new Bucket("images");

than it is to write code like

    let buck = new Bucket("images", {});
2017-05-22 14:08:32 -07:00