Commit graph

332 commits

Author SHA1 Message Date
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
Luke Hoban
cfc25552e1 Move APIGateway resources to use ARNs as IDs
Uses the ARN format roughly as described at:
http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-control-access-using-iam-policies-to-create-and-manage-api.html

Deployments do not have a defined ARN format, so we
follow a similar pattern as for Stages.
2017-06-04 12:10:29 -07:00
Luke Hoban
fd68aab8c3 Merge branch 'master' into apigateway 2017-06-04 10:53:36 -07:00
Luke Hoban
26a2f95c48 Support output properties on aws.apigateway APIs 2017-06-04 10:19:04 -07:00
joeduffy
048c35d428 Eliminate the @lumi.out decorator
The @lumi.out decorator ended up not being required after all.
The engine essentially treats all resource properties as potentially
output properties now, given the way we read back the state from
the provider after essential operations.

This is a good thing, because the evaluator currently doesn't
perform dynamic decoration in a way that would be amenable to
a faithful ECMAScript implementation (see pulumi/lumi#128).
2017-06-04 08:12:58 -07:00
Luke Hoban
92a9925201 Merge branch 'master' into apigateway 2017-06-03 14:58:23 -07:00
Luke Hoban
9f4d48b8f8 Address PR feedback on #194 2017-06-03 14:47:27 -07:00
Luke Hoban
ee987c9961 Add provider tests for aws.lambda.Function
Expands the resource provider test framework
to include support for provider tests which require
creating, updating and deleteing multiple resources.
2017-06-03 14:35:40 -07:00
Luke Hoban
5d2dffdcc9 Support Tags on aws.ec2.Instance
Also adds test coverage for aws.ec2.Instance resources.
2017-06-03 14:35:40 -07:00
joeduffy
cfaa7c9310 Eliminate use of nonstandard tools
This change eliminates the use of nonstandard tools in our build:

* `go test` automatically uses `GOMAXPROCS` for its parallelism
  setting.  In modern Go, this is now set to the number of processors.
  So, there is no need to set it explicitly using `nproc`.

* We can avoid `realpath` in the `lumijs` executable by making it
  a Node.js file and using a relative require import of main.

* We can avoid `realpath` in our Makefiles by just using `pwd`.
2017-06-03 11:08:09 -07:00
joeduffy
39db4dca63 Also build the Lumi stdlib during make all 2017-06-02 15:26:39 -07:00
Joe Duffy
8bbe89bd75 Makeify more; add a "full build" target (#193)
* Makeify more; add a "full build" target

This change uses make for more of our tree.  Namely, the AWS provider
and LumiJS compilers each now use make to build and/or install them.
Not only does this bring about some consistency to how we build and
test things, but also made it easy to add a full build target:

    $ make all

This target will build, test, and install the core Go tools, the LumiJS
compiler, and the AWS provider, in that order.

Each can be made in isolation, however, which ensures that the inner
loop for those is fast and so that, when it comes to finishing
pulumi/lumi#147, we can easily split them out and make from the top.
2017-06-02 14:26:34 -07:00
joeduffy
934802d54a Add some basic ARN tests 2017-06-02 08:13:38 -07:00
joeduffy
545906f38f Add a check for egress rules on EC2-Classic groups
If you try to specify egress rules on an EC2-Classic security group,
you get obscure error messages like "The parameter CidrIp is not recognized."
It turns out, the underlying AuthorizeSecurityGroupEgress function
isn't supported on EC2-Classic security groups (those w/out VPCs); see:
https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_AuthorizeSecurityGroupEgress.html

This change adds a check up front for this condition so developers get
a nicer error message.
2017-06-02 08:13:02 -07:00
Luke Hoban
6194945c27 Get Elastic Beanstalk sample working again
Changes the Source property on AWS S3 Objects
to be an `in` property.

Adds an AllOptionSettings output property to
store the settings returned from AWS.  This
unblocks keeping Beanstalk workign while
we evaluate options for #189.

Silently skip unsupported AWS ElasticBeanstalk
Environment properties in Get operation.

Fixes ARN resource name pair extraction to skip the
"/" between parts of the name pair.
2017-06-01 23:09:51 -07:00
Luke Hoban
5358080ca6 Output property improvements for AWS Function and Role
The AssumeRolePolicyDocument property returned by the AWS IAM GetRole API returns
a URL-encoded JSON string, so we need to decode this before JSON unmarshalling.

The Code property returned by AWS Lambda GetFunction provides a pre-signed S3 URL,
which changes on each call, and is of a different format to what is provided by the user.
For now, we'll not store this back into the Function object.

Add additional output properties to AWS Lambda Function that are stable values returned
from GetFunction.

Also corrects a gap where some property delete operations were not being correctly reported.
2017-06-01 15:04:37 -07:00
joeduffy
e2cb211d93 Enable parallel tests
This change enables parallelism for our tests.

It also introdues a `test_core` Makefile target to just run the
core engine tests, and not the providers, since they take a long time.
This is intended only as part of the inner developer loop.
2017-06-01 14:01:26 -07:00
joeduffy
fff4a9e8af Respond to CR feedback on PR #186
This change responds to some great feedback from @lukehoban on
https://github.com/pulumi/lumi/pull/186.  Namely:

* Relax many assertions in the providers.  A failure here is pretty
  bad because it takes down the entire provider due to fail-fast.
  That said, I'd rather fail in response to a bug than let it go
  silently.  Nevertheless, a few of them were candidates for dynamic
  failures.

* Use `aws.StringValue` and friends in more places.

* Remove a superfluous waitForTableState in DynamoDB.

* Fix some erroneous references to `Read` in some `Get` comments.
2017-06-01 13:25:49 -07:00
Luke Hoban
c117b43ae4 Update serverless API programming model
Updates  the higher level AWS APIGateway programming model
in aws.serverless.API  to use an Express-like imperative API.
2017-06-01 10:54:26 -07:00
joeduffy
8de9411697 Mark instance security groups as replaces
Altering an instance's security group list used to imply a replace, but
it must have gotten broken somewhere along the line during the IDL updates.
(We desperately need those test cases...)  For now, we will mark the groups
as `replaces, and when we get around to pulumi/lumi#187, we'll fix this.
2017-06-01 10:39:21 -07:00
joeduffy
7b5f9df917 Make updates work in the face of output properties
This change fixes up a few things so that updates correctly deal
with output properties.  This involves a few things:

    1) All outputs stored on the pre snapshot need to get propagated
       to the post snapshot during planning at various points.  This
       ensures that the diffing logic doesn't need to be special cased
       everywhere, including both the Lumi and the provider sides.

    2) Names are changed to "input" properties (using a new `lumi` tag
       option, `in`).  These are properties that providers are expected
       to know nothing about, which we must treat with care during diffs.

    3) We read back properties, via Get, after doing an Update just like
       we do after performing a Create.  This ensures that if an update
       has a cascading impact on other properties, it will be detected.

    4) Inspecting a change, prior to updating, must be done using the
       computed property set instead of the real one.  This is to avoid
       mutating the resource objects ahead of actually applying a plan,
       which would be wrong and misleading.
2017-06-01 10:09:52 -07:00
joeduffy
b5df277815 Fix a few merges when this branch hit master 2017-06-01 08:51:33 -07:00
joeduffy
41dc9610ad Fix two minor AWS provider issues
* The EC2 instance get function needs to return security group ARNs, not raw IDs.

* The EC2 security group rule CRUD operations printed pointers and not the values.
2017-06-01 08:39:48 -07:00
joeduffy
1d8835a810 Implement the remaining get functions 2017-06-01 08:39:48 -07:00
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
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
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
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
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
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
Luke Hoban
35a41f9e4a Support Update on IAM Role and Lambda Function 2017-05-22 22:57:55 -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
Luke Hoban
9a898d88fd Add AWS DynamoDB Table provider (#151)
Adds support for Table resources, along with the beginnings of a Serverless example that uses Tables.
2017-05-21 22:17:56 -07:00
Luke Hoban
0f99762e2e Add AWS Elastic Beanstalk resource providers (#154)
Includes support for:
* Application
* ApplicationVersion
* Environment
2017-05-21 21:45:28 -07:00
joeduffy
bb0822f2df Remove the Kube Fission provider
This code has moved out into its own distinct repo at pulumi/kubefission-lumipack.
2017-05-19 16:44:33 -07:00
joeduffy
ed092213d2 Remove deprecated lumix package 2017-05-19 16:27:34 -07:00
Luke Hoban
2a036c8693 More CLIDL -> LUMIDL updates 2017-05-18 17:21:08 -07:00
joeduffy
558d35e9cd Add back a missing package ec2
This was mistakenly lopped off during the license conversation.
2017-05-18 15:54:07 -07:00
joeduffy
4108c51549 Reclassify Lumi under the Apache 2.0 license
This is part of pulumi/lumi#147.
2017-05-18 14:51:52 -07:00
joeduffy
b7f3d447a1 Preserve the lumi prefix on our CLI tools
This change keeps the lumi prefix on our CLI tools.

As @lukehoban pointed out in person, as soon as we do pulumi/coconut#98,
most people (other than compiler authors themselves) won't actually be
typing the commands.  And, furthermore, the commands aren't all that bad.

Eventually I assume we'll want something like `lumi-js`, or
`lumi-js-compiler`, so that binaries are discovered dynamically in a way
that is extensible for future languages.  We can tackle this during #98.
2017-05-18 12:38:58 -07:00
joeduffy
dafeb77dff Rename Coconut to Lumi
This is part of pulumi/coconut#147.

After it has landed, I will rename the repo on GitHub.
2017-05-18 11:38:28 -07:00
joeduffy
3849761065 Rewrite Mantle functions to use assets/archives 2017-05-13 20:13:58 -04:00
joeduffy
ea7658f338 Guard against nil diffs 2017-05-08 14:52:17 -05:00
joeduffy
1e67162331 Fix a couple silly mistakes 2017-05-04 09:53:52 -07:00
joeduffy
70e75063c2 Remove superfluous output from install.sh 2017-05-01 17:43:50 -07:00
joeduffy
7f634b4cf2 Remove pulumi/coconut#141 workaround 2017-05-01 17:13:30 -07:00
joeduffy
bcd44fc06f Update cross-cloud library to support the latest changes 2017-05-01 10:21:52 -07:00
joeduffy
08626715fd Revert change to managed policy ARN casing 2017-05-01 10:17:18 -07:00
joeduffy
c1696dc684 Regenerate Kubefission with latest CIDLC 2017-05-01 09:41:02 -07:00
joeduffy
6902d7e1b2 Update AWS Lambdas to take archives, not assets 2017-05-01 09:38:23 -07:00
joeduffy
335ea01275 Implement archives
Our initial implementation of assets was intentionally naive, because
they were limited to single-file assets.  However, it turns out that for
real scenarios (like lambdas), we want to support multi-file assets.

In this change, we introduce the concept of an Archive.  An archive is
what the term classically means: a collection of files, addressed as one.
For now, we support three kinds: tarfile archives (*.tar), gzip-compressed
tarfile archives (*.tgz, *.tar), and normal zipfile archives (*.zip).

There is a fair bit of library support for manipulating Archives as a
logical collection of Assets.  I've gone to great length to avoid making
copies, however, sometimes it is unavoidable (for example, when sizes
are required in order to emit offsets).  This is also complicated by the
fact that the AWS libraries often want seekable streams, if not actual
raw contiguous []byte slices.
2017-04-30 12:37:24 -07:00
joeduffy
35a86d9089 Move AWS instanceMaps module back to ec2 2017-04-29 16:01:13 -07:00
joeduffy
0e16aa5d93 Make resource names the first constructor parameter
This reverts back to the old style of having the resource name as its
first parameter in the generated package.  Stylistically, this reads a
little nicer, and also ensures we don't need to rewrite all our existing
samples/test cases, etc.
2017-04-29 15:58:34 -07:00
joeduffy
fa24d436e3 Unpointerize some types
In a few places, an IDL type will be a pointer, but the resulting
RPC code would, ideally, be the naked type.  Namely, in both resource
and asset cases, they are required to be pointers in the IDL (because
they are by-pointer by nature), but the marshaled representations need
not be pointers.  This change depointerizes such types in the RPC
unless, of course, they are optional in which case pointers still make
sense.  This avoids some annoying dereferencing and is the kind of thing
we want to do sooner before seeing widespread use.
2017-04-29 15:38:56 -07:00
joeduffy
fe93f5e76f Strongly type resource IDs in the IDL/RPC/Providers
This change simply uses the `resource.ID` type in all the places
where it belongs, rather than using `string`-typed resource IDs.
2017-04-29 13:27:39 -07:00
joeduffy
d8627697df Unglide AWS provider
This triggers complicates with local development, due to the way
that Glide vendors dependencies.  After we move to distinct repos
for the various provider packages, we can go back to doing this.
2017-04-29 13:26:39 -07:00
joeduffy
2e49e87e38 Add an IDL generation script for Kube Fission 2017-04-29 13:23:26 -07:00
joeduffy
1a0066b938 Commit generated code for Kube Fission package 2017-04-28 16:37:10 -07:00
joeduffy
8bb31a8dd9 Migrate Kube Fission provider to new IDL model 2017-04-28 16:36:43 -07:00
joeduffy
d1dccb1b0a Further simplify the AWS provider
Now that the IDL types encode named resources as a first class concept,
there is no need to do the dynamic overriding dance in the AWS provider.
I should have included this in my final "banking" of the IDL changes.
2017-04-28 16:18:19 -07:00
joeduffy
3d391f3a44 Add the AWS package's CIDLC generated code
This change includes all of the CIDLC generated code for the AWS
package.  Just as we vendor and version the generated gRPC code,
we will do so for these files also.  This allows building of the
full packages without needing to run any special tools, in addition
to letting us keep track of generated code deltas over time.
2017-04-28 15:40:40 -07:00
joeduffy
3a4866f7c1 Add manually managed AWS package files
This checkin contains all the non-generated package files.  This includes
the package metadata, utility functions like utils/instanceMaps, and the
module layouts (these being a candidate for auto-generation down the road).

In addition, the install script has been updated fo reflect the new layout.
2017-04-28 15:38:45 -07:00
joeduffy
ec03441a15 Eliminate old TypeScript resource definitions
The old TypeScript resource definitions may now go away in favor of
the new IDL and associated generated code.  After this change, I will
check in the generated code, so that the repo is self-contained.
2017-04-28 15:36:22 -07:00
joeduffy
aca61a2074 Add missing Lambda Permisssion IDL type 2017-04-28 15:29:13 -07:00
joeduffy
59573fc05f Finish projecting AWS IDL types
This converts the remaining AWS resource types over to the new IDL
model; this includes the apigateway, cloudwatch, sns, and sqs packages.
2017-04-28 15:22:44 -07:00
joeduffy
e2e73cf035 Use good package names in place of "rpc"
This is just a minor stylistic change.  Instead of letting the AWS
package imports take the good names, prefer to use the generated IDL
names (since they contain the strongly typed data structures).
2017-04-28 13:04:10 -07:00
joeduffy
93255b7e8f Convert the AWS S3 provider to the new IDL model 2017-04-28 12:58:51 -07:00
joeduffy
1489a73b18 Convert the AWS Lambda module to CIDLC 2017-04-28 12:27:19 -07:00
joeduffy
2d109f736c Convert AWS IAM types and provider to new IDL model 2017-04-28 11:16:49 -07:00
joeduffy
72b4035f3a Add a script to regenerate the AWS package from IDL 2017-04-28 10:37:37 -07:00
joeduffy
df01db5df7 Finish converting the AWS EC2 resource IDLs 2017-04-27 11:53:32 -07:00
joeduffy
70f6d88a5b Implement the basic ARN/Region IDL types 2017-04-27 11:29:51 -07:00
joeduffy
47ef3f673b Rename PreviewUpdate (again)
Unfortunately, this wasn't a great name.  The old one stunk, but the
new one was misleading at best.  The thing is, this isn't about performing
an update -- it's about NOT doing an update, depending on its return value.
Further, it's not just previewing the changes, it is actively making a
decision on what to do in response to them.  InspectUpdate seems to convey
this and I've unified the InspectUpdate and Update routines to take a
ChangeRequest, instead of UpdateRequest, to help imply the desired behavior.
2017-04-27 11:18:49 -07:00
joeduffy
617ac91c92 Convert the AWS EC2 Instance provider to the new IDL model 2017-04-27 11:07:16 -07:00
joeduffy
43bb3ec766 Reject non-pointer optional fields
This change rejects non-pointer optional fields in the IDL.  Although
there is no reason this couldn't work, technically speaking, it's almost
always certainly a mistake.  Better to issue an error about it; in the
future, we could consider making this a warning.
2017-04-27 11:03:13 -07:00
joeduffy
7b66ae2be5 Add the AWS EC2 VPC IDL
This change includes just the AWS EC2 VPC IDL, and not the corresponding
provider (which is not yet implemented in our system anyway).
2017-04-27 10:49:46 -07:00
joeduffy
d88773b773 Convert AWS EC2 SecurityGroup to the new IDL model 2017-04-27 10:42:35 -07:00
joeduffy
d3899981e0 Make AWS instance DNS/IP outputs optional 2017-04-25 14:03:42 -07:00
Eric Rudder
f8405325db Fixed typo 2017-04-24 09:16:56 -07:00
joeduffy
4671e5f435 Take an initial cut at AWS API Gateway support in Mantle
There are still several loose ends, but this sketches out the
overall shape of the API Gateway usage in Mantle.
2017-04-21 16:47:31 -07:00
joeduffy
0827ca5b58 Implement creation outputs for AWS resources
This change implements the appropriate creation outputs for AWS
resource providers, both on the IDL side and in the providers themselves.
2017-04-21 16:14:59 -07:00
joeduffy
a2b37d7dda Implement an aws.ARN type
This "strongly types" the aws.ARN type.  In reality, it is simply an
alias for a string at the moment (as this is what it boils down to on
the wire), but this at least gets us some amount of compile-time safety.
2017-04-21 14:03:06 -07:00
joeduffy
9b9fac4254 Make iam.Role's managed policy ARNs a string list 2017-04-21 13:27:34 -07:00
joeduffy
cb10ec7014 Mark lambda.Permission's source args as optional 2017-04-21 13:24:56 -07:00
joeduffy
6a6b82e2ab Add the AWS lambda.Permission resource IDL 2017-04-21 13:23:13 -07:00
joeduffy
689dd06949 Add AWS API Gateway resource IDL definitions
This change includes resource IDL definitions for all of AWS API Gateway's
corresponding CloudFormation resource types.  There are no actual provider
implementations yet.
2017-04-21 10:15:19 -07:00
joeduffy
fdd441fd25 Implement the Kubernetes Fission HTTPTrigger provider 2017-04-20 18:40:05 -07:00
joeduffy
3f25aca7dd Add a http.API abstraction to Mantle
This introduces an http.API abstraction to Mantle and implements it
for Kubernetes Fission.  (The AWS implementation will come shortly,
but requires a fair bit of API Gateway elbow grease first.)

This lets you invoke a function in response to an API event:

    let func = new mantle.func.Function(
        (e, ctx, cb => { ... },
    );
    let api = new mantle.http.API("/hello", "GET", func);
2017-04-20 16:05:19 -07:00
joeduffy
0b6e262b46 Rename resource provider methods
This change renames two provider methods:

    * Read becomes Get.

    * UpdateImpact becomes PreviewUpdate.

These just read a whole lot nicer than the old names.
2017-04-20 14:09:00 -07:00
joeduffy
8eecc2c05b Flatten Fission metadata property
This change flattens the Fission metadata property on the Coconut
side so that it is nicer to consume.  Due to struct embedding in Go,
we need to perform translation at the serialization boundary anyway,
so the less-usable approach we had before didn't really buy us anything.
2017-04-19 16:05:33 -07:00
joeduffy
da73d81dd0 Implement the Fission function provider 2017-04-19 15:52:17 -07:00
joeduffy
47a9a6ee08 Implement Kubernetes functions
This change detects when the target scheduler is Kubernetes, and prefers
to schedule atop Fission functions.
2017-04-19 15:36:48 -07:00
joeduffy
cc6dd63556 Use inter-resource references for Fission resources
The Fission internal data structures reference one another by
name/URI.  Coconut needs the graph with dependencies, however, so
we prefer to model things using real object references in these
situations.  (This also makes it much nicer to program.)  This
changes to fit the Coconut model better; the provider will then
turn around and present names/URIs to the various APIs.
2017-04-19 15:33:33 -07:00
joeduffy
cbd3692d3d Initialize the logging libraries 2017-04-19 15:05:18 -07:00
joeduffy
958d67d444 Move NewCheckResponse into coconut/pkg/resource package 2017-04-19 14:25:49 -07:00
joeduffy
366e236853 Implement the Fission provider scaffolding; and Environments 2017-04-19 14:23:01 -07:00
joeduffy
1abda1b49e Glide the AWS provider package 2017-04-19 12:04:24 -07:00
joeduffy
ad87006611 Add an @asset decorator, and a Code asset type
This change introduces an @asset decorator in addition to a Code
asset type.  The idea here is that compilers will recognize the
presence of @asset and react by spewing the code as a textual
asset, rather than an AST and/or actually getting compiled into IL.
2017-04-19 11:43:33 -07:00
joeduffy
48677d8809 Fix some paths
😳
2017-04-19 11:26:41 -07:00
joeduffy
cc37a8078d Implement a basic Fission (Kubernetes FaaS) resource package
This change introduces some resource IDL types for the Fission
project (https://github.com/fission/fission), which is a
functions-as-a-service (FaaS) substrate on top of Kubernetes.

It has a single configuration variable,
`kube-fission:config:controller`, which controls the address of
the Fission controller in the target Kubernetes cluster.

Someday, ideally we would rebuild this atop a more general
Kubernetes resource package, and add some sort of discovery of
this controller, to minimize the amount of manual configuration
required and to make it more resilient to self-healing operations.

This is IDL-only.  The provider is coming soon.
2017-04-19 11:21:35 -07:00
joeduffy
c51fbd57c3 Introduce a new cross-cloud package, Mantle
This introduces a new experimental cross-cloud package, Mantle.  This is part
of getting pulumi/coconut#134 up and running.

For now, there isn't much here, except for configuration of the target cloud and
scheduler, plus the ability to create a cross-cloud function.  (OK, it's not truly
cross-cloud yet, since we have only implemented AWS Lambdas.)

Mantle is, of course, a placeholder name.  Since this is a higher level
abstraction than the unopinionated core primitives, the name mantle corresponds
to the Earth's upper layers (and I thought "Crust" would be a rather odd name).
2017-04-18 15:10:13 -07:00
joeduffy
da75f62865 Retry lambda creation until IAM role is available
Per Amazon's own documentation,
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html#launch-instance-with-role,
IAM roles may take "several seconds" to propagate.  In the meantime, we
are apt to get the dreaded "role defined for this function cannot be assumed"
error message.  In response, we'll do what the AWS documentation suggests:
wait a bit and retry.
2017-04-18 13:56:19 -07:00
joeduffy
74772f89e4 Use the role ARN, not its name, for lambda creation 2017-04-18 13:18:04 -07:00
joeduffy
973fccf09d Implement AWS Lambda resource provider
This change introduces a basic AWS Lambda resource provider.  It supports
C--D, but not -RU-, yet.
2017-04-18 11:02:04 -07:00
joeduffy
7878a44ef5 Export inlinePolicy fields 2017-04-17 18:06:12 -07:00
joeduffy
351981a409 Implement AWS IAM Role provider 2017-04-17 17:54:20 -07:00
joeduffy
4c5e13f241 Rearrange asset modules to read nicer 2017-04-17 17:24:08 -07:00
joeduffy
aed7e45d37 Project a smattering of new AWS resource types
This change introduces a bunch of new AWS resource types:

    * aws:iam/Group
    * aws:iam/Policy
    * aws:iam/Role
    * aws:iam/User
    * aws:kms/Key
    * aws:lambda/Function
    * aws:sqs/Queue

None of the associated resource providers are included; this is
an IDL-only projection of the types, their properties, and the
associated API documentation.  Lacking these is blocking me from
making progress on the cross-platform functions project.

It's a little unfortunate to be digging the hole deeper in advance
of pulumi/coconut#133 landing.  However, we are laser-focused on the
pulumi/coconut#134 prototype, so for now I'll just keep going.
2017-04-17 16:55:18 -07:00
joeduffy
b3f430186d Implement S3 bucket objects
This change includes a first basic whack at implementing S3 bucket
objects.  It leverages the assets infrastructure put in place in the
last commit, supporting uploads from text, files, or arbitrary URIs.

Most of the interesting object properties remain unsupported for now,
but with this we can upload and delete basic S3 objects, sufficient
for a lot of the lambda functions management we need to implement.
2017-04-17 13:34:19 -07:00
joeduffy
67248789b3 Introduce assets
This change introduces the basic concept of assets.  It is far from
fully featured, however, it is enough to start adding support for various
storage kinds that require access to I/O-backed data (files, etc).

The challenge is that Coconut is deterministic by design, and so you
cannot simply read a file in an ad-hoc manner and present the bytes to
a resource provider.  Instead, we will model "assets" as first class
entities whose data source is described to the system in a more declarative
manner, so that the system and resource providers can manage them.

There are three ways to create an asset at the moment:

1. A constant, in-memory string.
2. A path to a file on the local filesystem.
3. A URI, whose scheme is extensible.

Eventually, we want to support byte blobs, but due to our use of a
"JSON-like" type system, this isn't easily expressible just yet.

The URI scheme is extensible in that file://, http://, and https://
are supported "out of the box", but individual providers are free to
recognize their own schemes and support them.  For instance, copying
one S3 object to another will be supported simply by passing a URI
with the s3:// protocol in the usual way.

Many utility functions are yet to be written, but this is a start.
2017-04-17 13:00:26 -07:00
joeduffy
89eccfad94 Add an AWS S3 bucket resource and provider 2017-04-17 10:46:19 -07:00
joeduffy
9568954187 Use coco instead of coconut during install 2017-04-17 10:38:03 -07:00
joeduffy
d23d3a5f87 Add the instance maps to the AWS library
For now, this makes the demo nicer; eventually, we probably want
to consider factoring this out into a separate "awsutils" package.
2017-03-15 19:54:29 -07:00
joeduffy
432105d627 Add an enum union type for AWS instance types 2017-03-15 16:12:24 -07:00
joeduffy
95f59273c8 Update copyright notices from 2016 to 2017 2017-03-14 19:26:14 -07:00
joeduffy
774ed45ccc Add an example cpuwatch package
This change includes a simple cpuwatch package, as a demonstration of
how easy it can be to add CPU-level monitoring to an existing stack.

It contains a single API, enableAlarm, that takes an instance and
CPU % threshold; if the CPU ever exceeds that threshold for a sustained
period of time (3 consecutive minutes), an email will be generated.

To use this, first simply install the package as usual, e.g.

    $ coco pack get cpuwatch

From there, you will need to configure the email address to send to:

    $ coco env config <env> cpuwatch:config:emailAddress joe@pulumi.com

And finally, add an import plus call to enableAlarm for all instances:

    import * as cpuwatch from "cpuwatch";
    ..
    let instance = new aws.ec2.Instance(...);
    cpuwatch.enableAlarm(instance, 90); // email if >90% CPU utilization.

As part of this, I've added the typing projections for the AWS SNS topic
and CloudWatch alarm resource types (but no providers just yet).
2017-03-13 12:26:33 -07:00
joeduffy
80d19d4f0b Use the object mapper to reduce provider boilerplate
This changes the object mapper infrastructure to offer more fine-grained
reporting of errors, and control over verification, during the mapping from
an untyped payload to a typed one.  As a result, we can eliminate a bit of
the explicit unmarshaling goo in the AWS providers (but not all of it; I'm
sure there is more we can, and should, be doing here...)
2017-03-12 14:13:44 -07:00
joeduffy
705880cb7f Add the ability to specify analyzers
This change adds the ability to specify analyzers in two ways:

1) By listing them in the project file, for example:

        analyzers:
            - acmecorp/security
            - acmecorp/gitflow

2) By explicitly listing them on the CLI, as a "one off":

        $ coco deploy <env> \
            --analyzer=acmecorp/security \
            --analyzer=acmecorp/gitflow

This closes out pulumi/coconut#119.
2017-03-11 10:07:34 -08:00
joeduffy
b4b4d26844 Add pkg/util/rpcutil to cut down on some plugin boilerplate
This change eliminates some of the boilerplate required to create a
new plugin; mostly this is gRPC-related code.
2017-03-11 09:23:09 -08:00
joeduffy
c36bb75653 Simplify the library README 2017-03-11 09:01:33 -08:00
joeduffy
78407a7477 Check AMI validity
This change checks that the AMI referenced in an instance provisioning
is valid.  If not, the deployment is rejected before even trying.  This
is part of pulumi/coconut#115.
2017-03-10 22:34:25 -08:00
joeduffy
807d355d5a Rename plugin prefix from coco-ressrv to coco-resource 2017-03-10 20:48:09 -08:00
joeduffy
e3e62e55b2 Fix install scripts to use coco pack verify 2017-03-10 09:37:16 -08:00
joeduffy
08c1b10e75 Fix some CocoJS runtime issues
This change fixes up a handful of CocoJS runtime issues preventing
it from compiling; we aren't using much of this yet, but I hope to
resurrect it soon (so more legal ECMAScript code can run).
2017-03-10 09:35:52 -08:00
joeduffy
86dc13ed5b More term rotations
This changes a few naming things:

* Rename "husk" to "environment" (`coco env` for short).

* Rename NutPack/NutIL to CocoPack/CocoIL.

* Rename the primary Nut.yaml/json project file to Coconut.yaml/json.

* Rename the compiled Nutpack.yaml/json file to Cocopack.yaml/json.

* Rename the package asset directory from nutpack/ to .coconut/.
2017-03-06 14:32:39 +00:00
joeduffy
9044047b84 Fix a go vet failure 2017-03-06 13:02:48 +00:00
joeduffy
7cb9ce2663 Implement some AWS provider checking
This change refactors the existing property verification logic for
the AWS provider to use the new checking capabilities.  Beyond just
checking for required properties, there isn't much here yet.  There
is a single check for security group description length that goes
beyond this, mostly for illustration purposes.

This is part of pulumi/coconut#115, although there is clearly more
to do here for something sufficiently snazzy and demoable.
2017-03-03 12:13:19 -08:00
joeduffy
2ce75cb946 Make security group changes imply replacement 2017-03-02 16:16:18 -08:00
joeduffy
966969945b Add a resource.NewUniqueHex API (and use it)
This change adds a new resource.NewUniqueHex API, that simply generates
a unique hex string with the given prefix, with a specific count of
random bytes, and optionally capped to a maximum length.

This is used in the AWS SecurityGroup resource provider to avoid name
collisions, which is especially important during replacements (otherwise
we cannot possibly create a new instance before deleting the old one).

This resolves pulumi/coconut#108.
2017-03-02 16:02:41 -08:00
joeduffy
523c669a03 Track which updates triggered a replacement
This change tracks which updates triggered a replacement.  This enables
better output and diagnostics.  For example, we now colorize those
properties differently in the output.  This makes it easier to diagnose
why an unexpected resource might be getting deleted and recreated.
2017-03-02 15:24:39 -08:00
joeduffy
c633d0ceb0 Add "still waiting" messages to retries 2017-03-02 13:12:40 -08:00
joeduffy
da5e737e08 Update EC2 resources to new Update model 2017-03-02 10:02:05 -08:00
joeduffy
bd613a33e6 Make replacement first class
This change, part of pulumi/coconut#105, rearranges support for
resource replacement.  The old model didn't properly account for
the cascading updates and possible replacement of dependencies.

Namely, we need to model a replacement as a creation followed by
a deletion, inserted into the overall DAG correctly so that any
resources that must be updated are updated after the creation but
prior to the deletion.  This is done by inserting *three* nodes
into the graph per replacement: a physical creation step, a
physical deletion step, and a logical replacement step.  The logical
step simply makes it nicer in the output (the plan output shows
a single "replacement" rather than the fine-grained outputs, unless
they are requested with --show-replace-steps).  It also makes it
easier to fold all of the edges into a single linchpin node.

As part of this, the update step no longer gets to choose whether
to recreate the resource.  Instead, the engine takes care of
orchestrating the replacement through actual create and delete calls.
2017-03-02 09:52:08 -08:00
joeduffy
8698e5abeb Implement replacement for EC2 instances 2017-03-01 13:42:10 -08:00