Commit graph

279 commits

Author SHA1 Message Date
Luke Hoban
bcc37d78a8 Nightly test fixes
Fix a couple of issues that have been preventing nightlies
from running cleanly.
2017-06-20 12:29:04 -07:00
Luke Hoban
6b7616ce1a Merge branch 'master' of https://github.com/pulumi/lumi 2017-06-20 10:30:27 -07:00
joeduffy
26cf93f759 Implement get functions on all resources
This change implements the `get` function for resources.  Per pulumi/lumi#83,
this allows Lumi scripts to actually read from the target environment.

For example, we can now look up a SecurityGroup from its ARN:

    let group = aws.ec2.SecurityGroup.get(
        "arn:aws:ec2:us-west-2:153052954103:security-group:sg-02150d79");

The returned object is a fully functional resource object.  So, we can then
link it up with an EC2 instance, for example, in the usual ways:

    let instance = new aws.ec2.Instance(..., {
        securityGroups: [ group ],
    });

This didn't require any changes to the RPC or provider model, since we
already implement the Get function.

There are a few loose ends; two are short term:

    1) URNs are not rehydrated.
    2) Query is not yet implemented.

One is mid-term:

    3) We probably want a URN-based lookup function.  But we will likely
       wait until we tackle pulumi/lumi#109 before adding this.

And one is long term (and subtle):

    4) These amount to I/O and are not repeatable!  A change in the target
       environment may cause a script to generate a different plan
       intermittently.  Most likely we want to apply a different kind of
       deployment "policy" for such scripts.  These are inching towards the
       scripting model of pulumi/lumi#121, which is an entirely different
       beast than the repeatable immutable infrastructure deployments.

Finally, it is worth noting that with this, we have some of the fundamental
underpinnings required to finally tackle "inference" (pulumi/lumi#142).
2017-06-19 17:29:02 -07:00
Luke Hoban
ac4a56bb6d Additional tslint cleanup in examples 2017-06-19 17:09:55 -07:00
Luke Hoban
c265620f28 Makefile updates
Make nightly tests more verbose to avoid 10 minute
timeout in Travis when we have no test output.

Run aws provider tests by default again on full builds.
2017-06-17 15:43:50 -07:00
Britton Forsyth
2d639abcf1 Added typescript linting to Makefiles (#248)
Added necessary tslint.json files to Makefile locations and enabled tslint at these under the lib folder to lint as part of the build.
2017-06-16 18:01:36 -07:00
joeduffy
5f9ed13069 Simplify Check; make it tolerant of computed values
This change simplifies the generated Check interface for providers.
Instead of

    Check(ctx context.Context, obj *T) ([]error, error)

where T is the resource type, we have

    Check(ctx context.Context, obj *T, property string) error

This is done so that we can drive the calls to Check one property
at a time, allowing us to skip any that are computed.  (Otherwise,
we may fail the verification erroneously.)

This has the added advantage that the Check implementations are
simpler and can simply return a single error.  Furthermore, the
generated RPC code handles wrapping the result, so we can just do

    return errors.New("bad");

rather than the previous reflection-laden junk

    return resource.NewFieldError(
        reflect.TypeOf(obj), awsservice.AWSResource_Property,
        errors.New("bad"))
2017-06-16 13:34:11 -07:00
Luke Hoban
d862112682 Fix Makefile target names
Fix copy/paste issue in some new Makefile targets.
2017-06-16 10:34:34 -07:00
Luke Hoban
e27549e5c2 Add nightly build target
Adds a nightly build target that runs the long running provider
and examples tests.  Enables travis to run this on cron jobs,
which we will configure to trigger nightly.
2017-06-16 09:53:07 -07:00
Luke Hoban
6840dba051 Move examples test to seperate package
We need to run examples tests only after building and
installing all Lumi commands.
2017-06-16 09:24:31 -07:00
Luke Hoban
639a2d323d Test more examples
Tests all of our commonly used examples.

Also sets test parallelism to 10 by default
since we are I/O bound on API calls to
the resource providers.

Also avoids using larger EC2 examples in
our samples so that we can keep our test
costs lower :-).
2017-06-16 09:24:31 -07:00
Luke Hoban
ae03d69645 Wire up APIs to lambdas using output properties
We now have enough output properties implementation
working to change our API gateway examples and API
wrapper to correctly wire the API routes to the ARNs of
lambdas passed in to them.

We both wire up the lambda to the route, but also create
a permission specific to each route to assign to the
corresponding lambda - providing least privelege needed
for the API definition.

Also adds `string#toUpperCase` and fixes NewUniqueHex
to match how we are using it.
2017-06-15 16:01:00 -07:00
Luke Hoban
1a21dd8368 Skip provider tests when AWS credentials are unavailable (#250)
Instead of asserting, we will skip these tests if the environment
does not provide access to credentials to create an AWS context.

This fixes #232.
2017-06-15 10:58:46 -07:00
Luke Hoban
1ba0bf7f95 Fix the serverless API example
The aws.serverless.API component was previously relying
on the fact that Lumi delayed resource creation until the
program was done executing.  With the changes to execution
for output properties, this no longer works.

For now, we will address this by change API to create the
RestAPI resource at the time of `publish`, after all of the
routes are already defined.
2017-06-15 09:06:40 -07:00
joeduffy
9698309f2b Model resource ID and URN as output properties
This change exposes ID and URN properties on resources, as appropriate,
so that they may be read and used in Lumi scripts.
2017-06-14 17:00:13 -07:00
joeduffy
54b19a5a42 Add missing yarn link to Makefile 2017-06-13 18:19:04 -07:00
joeduffy
a42b40f1a8 Refactor runtime functionality
This change splits the core Lumi library -- which is meant to be a pure
LumiJS library without any special status -- from the runtime library --
which is really meant to be the underpinnings of "special" functionality
that integrates with the runtime in sophisticated ways.

After this change, LumiRT is at the very bottom, and, despite it using
a subset of LumiJS, it must not trigger any functionality that would
mandate the use of the LumiJS runtime library.  Atop that, the LumiJS
library is layered.  And finally, above that, Lumi depends on LumiJS.
2017-06-13 18:11:59 -07:00
Luke Hoban
3a47f2ca72 Merge remote-tracking branch 'origin/master' into bforsyth927-gometalinter 2017-06-13 18:04:36 -07:00
joeduffy
1411f33c0c Print the install location in some Makefiles 2017-06-13 17:14:34 -07:00
Luke Hoban
282f40d3e3 Merge branch 'master' into bforsyth927-gometalinter 2017-06-13 16:28:12 -07:00
Luke Hoban
cdd5471cfe Merge branch 'gometalinter' of https://github.com/bforsyth927/lumi into bforsyth927-gometalinter 2017-06-13 16:15:12 -07:00
Britton Forsyth
01003ad48b Implemented highlighted edits 2017-06-13 11:01:23 -07:00
joeduffy
dedeab3c5e Update test util to use new packages
Also add a license, fix some long lines, and make it gofmt clean.
2017-06-13 07:10:13 -07:00
joeduffy
d277dd5800 More progress on pulumi/lumi#90
This change refactors a number of aspects of the CLI's treatment of
steps, in line with the new scheme, and a number of other miscellaneous
and minor fixes.  It also regenerates all RPC code impacted by recent renames.
2017-06-13 07:10:13 -07:00
Luke Hoban
29fcde459b Add demo script and raw serverless example
Adds an initial cut at a demo script along with
a raw version of the serverless example that
is a better stepping stone between the low-level
AWS infrastructure providers and the high-level
`aws.serverless` APIs.
2017-06-12 15:20:37 -07:00
Luke Hoban
2914505a08 Expose the HTTP URL as an APIGateway Stage output property
Adds two output properties on APIGateway Stage resources.
* `url` is the full URL to the root of the deployed stage.
* `executionARN` is the arn needed to pass to Lambda to
give the stage permission to invoke a Lambda handler.
2017-06-12 10:40:41 -07:00
Luke Hoban
9bd441be05 Support for nested lambdas and node_modules
LumiJS lambdas can now be serialized when they include calls to other LumiJS lambdas.  The chain of lambda dependencies is jointly serialized into the target Lambda.

Also, LumiJS lambdas now include `node_modules` automatically in the AWS Lambda, ensuring the the runtime execution environment more closely matches the deployment time environment.

An early version of the gh-cicd example supporting #134 is added which uses these capabilities, currently including a mocked GitHub resource provider.
2017-06-12 10:15:20 -07:00
joeduffy
19febfcd9a Use a typedef for serverless function handler 2017-06-12 08:38:11 -07:00
joeduffy
2b7b8c6160 Increase the default AWS timeout
We just hit a CI failure due to a timeout waiting for a lambda's
permissions to become available.  The AWS documents say "it may take
a few seconds", which is remarkably unhelpful.  Our current default
wait time is 30 seconds.  I am bumping it to 1 minute.

I also filed pulumi/lumi#233 for future consideration, since I would
like to think we can be more principled in our approach here...
2017-06-10 12:45:36 -07:00
joeduffy
7fb9a977db Fix a typo: "intance" should be "instance" 2017-06-10 12:15:03 -07:00
Britton Forsyth
69e4834f63 Merge branch 'master' into gometalinter 2017-06-09 14:34:51 -07:00
Luke Hoban
2870e8a0b1 Merge branch 'gometalinter' of https://github.com/bforsyth927/lumi into bforsyth927-gometalinter 2017-06-09 10:30:50 -07:00
Luke Hoban
7171b58459 Address PR feedback on #229 2017-06-09 10:15:03 -07:00
Britton Forsyth
13dbcdbafc Finalized tslint edits and deletes 2017-06-09 08:54:05 -07:00
Luke Hoban
d77c51ff7f Allow runtime lambda to reference globals.
For lambdas which will execute at runtime,
we want to allow them to reference Node.js
global variables, like `console`.

This change makes Lumijs generated IL
incrementally more dynamic by preferring to
generate `TryLoadDynamic` over `LoadLocation`
for references to global variables (except for
references to imports).

Also introduces `console.log` in LumiJS, though
it is not yet attached to a Lumi global environment.

Fixes #174.
2017-06-08 22:06:41 -07:00
Britton Forsyth
11c74f12d9 Fixed tslint issues 2017-06-08 16:40:12 -07:00
Luke Hoban
771a30c688 Save build artifacts aftifacts for Go builds
In the places we run `go build`, we should use
`go build -i` to save the `.a` files generated
during the build.  This ensures the artifacts
are availble for other Go tools (linters, IDEs), and
should also improve build speeds.
2017-06-07 17:03:07 -07:00
Luke Hoban
96c25a9614 Generate valid Permission names for aws.serverless.API
The previous checkin exposed some validation
errors that had previously been surpressed,
including an error validating the Permission
statementId's generated by aws.serverless.API.
2017-06-07 16:34:17 -07:00
Luke Hoban
0f8bd74a82 Address PR feedback on #224
Adds Check implementation for aws.lambda.Permission
resources using AWS-defined regexps.

Fixes bug in lumidl Check wrapper which was dropping
reported check failures (an regen all rpc files).

Add calls to Get into the AWS provider test framework.
2017-06-07 15:13:56 -07:00
Luke Hoban
977e56e03e Add aws.lambda.Permission resource (#224)
Adds a Permission resource to enable lambda Functions
to be invoked by event sources.

Per #223, we are continuing to discuss whether these
should really be a seperate resource or just an inline
component of a Function resource.  However, until we
support cycle-breaking, we'll need them to be a separate
resource type.

Progress on #222.
2017-06-06 18:42:00 -07:00
joeduffy
f33b20e6cf Dereference some names; add some missing licenses 2017-06-06 15:19:32 -07:00
joeduffy
c7dc3036d7 Finish scrubbing TODOs
This is a final pass over our TODOs, and closes pulumi/lumi#212.
2017-06-06 06:05:35 -07:00
joeduffy
db99092334 Implement mapper.Encode "for real"
This change implements `mapper.Encode` "for real" (that is, in a way
that isn't a complete embarrassment).  It uses the obvious reflection
trickery to encode a tagged struct and its values as a JSON-like
in-memory map and collection of keyed values.

During this, I took the opportunity to also clean up a few other things
that had been bugging me.  Namely, the presence of `mapper.Object` was
always error prone, since it isn't a true "typedef" in the sence that
it carries extra RTTI.  Instead of doing that, let's just use the real
`map[string]interface{}` "JSON-map-like" object type.  Even better, we
no longer require resource providers to deal with the mapper
infrastructure.  Instead, the `Check` function can simply return an
array of errors.  It's still best practice to return field-specific errors
to facilitate better diagnostics, but it's no longer required; and I've
added `resource.NewFieldError` to eliminate the need to import mapper.

As of this change, we can also consistently emit RPC structs with `lumi`
tags, rather than `lumi` tags on the way in and `json` on the way out.

This completes pulumi/lumi#183.
2017-06-05 17:49:00 -07:00
Luke Hoban
658d4b3c8a Add array-valued output properties to RestAPI
These properties no longer trigger assertons after
work on #198.
2017-06-05 11:23:42 -07:00
Luke Hoban
09f2968d18 Decouple Deployment from Stage in aws.apigateway
The raw AWS API and CloudFormation projection allow
a stage to be created as part of creating a deployment.
This leads to difficulties tracking the ownership of this
extra stage, since it is neither created and owned
seperately, nor is it discoverable after the fact from the
deployment.

We can keep the API simpler by not projecting this feature
of the AWS API into the Lumi resource.  The stage will have
to be created seperately in Lumi, and it's lifecycle is well
understood as a separate Lumi resource.

Fixes #202.
2017-06-04 21:34:51 -07:00
joeduffy
c2f2fbd2ff Regenerate some code 2017-06-04 19:37:27 -07:00
joeduffy
87004a124e Store both input and output properties distinctly
This changes the resource model to persist input and output properties
distinctly, so that when we diff changes, we only do so on the programmer-
specified input properties.  This eliminates problems when the outputs
differ slightly; e.g., when the provider normalizes inputs, adds its own
values, or fails to produce new values that match the inputs.

This change simultaneously makes progress on pulumi/lumi#90, by beginning
tracking the resource objects implicated in a computed property's value.

I believe this fixes both #189 and #198.
2017-06-04 19:24:48 -07:00
Luke Hoban
6710b919ea Cleanup APIGateway ARN parsing 2017-06-04 14:58:50 -07:00
Luke Hoban
318bcf9542 Merge branch 'master' into apigateway 2017-06-04 13:59:39 -07:00
joeduffy
812cd4ea00 Revert "Eliminate the @lumi.out decorator"
This reverts commit 048c35d428.

I have a pending change that fixes this along with a number of
other issues (including pulumi/lumi#198 and pulumi/lumi#187),
however, it's going to take a little longer and I want to unblock.

This fixes pulumi/lumi#200.
2017-06-04 13:05:21 -07:00