Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(decdk) prototype for declarative CDK (decdk) #1618

Merged
merged 47 commits into from
Feb 13, 2019
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
2b42350
We can now generate JSON schema
Jan 25, 2019
275ae10
We can hydrate a CdkFormation model now
Jan 26, 2019
5d0141c
Add cdk.json
Jan 26, 2019
1e1d6c2
self-contained
Jan 27, 2019
f7a10c5
schema generation improvements
Jan 27, 2019
2780f90
expand serializable set by ignoring optional non-serializable props
Jan 27, 2019
f201e9b
use type info during deserialization
Jan 27, 2019
f650a36
support Fn::GetAtt for resources and constructs
Jan 27, 2019
a00ce86
apigateway: resourceForPath
Jan 27, 2019
d3e9d07
lambda: ApiEventSource
Jan 27, 2019
a8deea8
serverless: Function
Jan 27, 2019
63803e4
more declarative examples
Jan 27, 2019
c72ee74
support construct properties with references
Jan 27, 2019
272b9e9
print warnings when constructs are not serializable
Jan 27, 2019
39bb01a
deconstructing enum-like classes
Jan 27, 2019
f3910b8
ecs: make ContainerImage an enum-like class
Jan 27, 2019
1061c97
ecs: fix ctor signature of ContainerDefinition
Jan 27, 2019
eb8859b
add a few more declarative examples
Jan 27, 2019
701e243
allow Fn::GetAtt to be used for object refs too
Jan 27, 2019
2fe18db
feat(aws-lambda): specify event sources upon initialization
Jan 30, 2019
5399145
fix(dynamodb): require partitionKey
Jan 30, 2019
a208519
feat(dynamodb): SimpleTable
Jan 30, 2019
1f88881
decdk: support arbitrary classes
Jan 30, 2019
20f2ab7
Merge branch 'master' into offsite/declarative
Feb 5, 2019
ae247ae
Update examples to declare dynamo partition and sort keys declaratvely
Feb 5, 2019
a1cd517
Fix linting errors
Feb 5, 2019
0b94775
improve error reporting by tracking schema context
Jan 31, 2019
7336a69
some more examples
Jan 31, 2019
d2a2618
basic, initial and insufficient unit test
Feb 5, 2019
0f87854
Merge remote-tracking branch 'origin/master' into offsite/declarative
Feb 5, 2019
6617a74
misc
Feb 7, 2019
2ac9a85
Merge remote-tracking branch 'origin/master' into offsite/declarative
Feb 11, 2019
4098f6b
fix foreach script
Feb 12, 2019
a1ce99b
fix function import
Feb 12, 2019
c2b219f
apigateway: capitalize method names
Feb 12, 2019
e8c9cb9
fix package.json
Feb 12, 2019
f65d939
remove serverless::function
Feb 12, 2019
c9b47fb
kwargs + snapshot tests against examples
Feb 12, 2019
afac15b
Merge remote-tracking branch 'origin/master' into offsite/declarative
Feb 12, 2019
a86d18d
Merge branch 'master' into offsite/declarative
Feb 12, 2019
e8650e9
Merge remote-tracking branch 'origin/master' into offsite/declarative
Feb 13, 2019
8ce7e33
deconstruct kwargs in methods a little differently and respect requir…
Feb 13, 2019
938f1fe
emit schema on build
Feb 13, 2019
6d7bbee
update ecs and lambda examples
Feb 13, 2019
fb431e2
update readme
Feb 13, 2019
1cb7165
readme updates
Feb 13, 2019
8fbdfe3
add description in deps.js script + fix typo
Feb 13, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47,276 changes: 47,276 additions & 0 deletions examples/cdk-examples-declarative/cdk.schema.json

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions examples/cdk-examples-declarative/ecs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"$schema": "./cdk.schema.json",
"Resources": {
"VPC": {
"Type": "@aws-cdk/aws-ec2.VpcNetwork",
"Properties": {
"maxAZs": 1
}
},
"Cluster": {
"Type": "@aws-cdk/aws-ecs.Cluster",
"Properties": {
"vpc": { "Ref": "VPC" }
}
},
"MyTaskDef": {
"Type": "@aws-cdk/aws-ecs.TaskDefinition",
"Properties": {
"compatibility": "Fargate",
"family": "redis",
"cpu": "1024",
"memoryMiB": "1GB"
}
},
"ContainerDef": {
"Type": "@aws-cdk/aws-ecs.ContainerDefinition",
"Properties": {
"task": { "Ref": "MyTaskDef" },
"essential": true,
"memoryLimitMiB": 1024,
"image": {
"fromDockerHub": {
"name": "redis"
}
}
}
},
"Service": {
"Type": "@aws-cdk/aws-ecs.FargateService",
"Properties": {
"cluster": { "Ref": "Cluster" },
"taskDefinition": { "Ref": "MyTaskDef" }
}
}
}
}
2 changes: 2 additions & 0 deletions examples/cdk-examples-declarative/genschema
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
../../tools/decdk/bin/decdk > cdk.schema.json
15 changes: 15 additions & 0 deletions examples/cdk-examples-declarative/iam.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "./cdk.schema.json",
"Resources": {
"MyUser": {
"Type": "@aws-cdk/aws-iam.User"
},
"Policy": {
"Type": "@aws-cdk/aws-iam.Policy",
"Properties": {
"users": [ { "Ref": "MyUser"} ],
//TODO: can't add statements
}
}
}
}
16 changes: 16 additions & 0 deletions examples/cdk-examples-declarative/lambda.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "./cdk.schema.json",

"Resources": {
"Handler": {
"Type": "@aws-cdk/aws-lambda.Function",
"Properties": {
"handler": "index.handler",
"runtime": "NodeJS810",
"code": {
"asset": { "path": "./src" }
}
}
}
}
}
49 changes: 49 additions & 0 deletions examples/cdk-examples-declarative/pipeline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"$schema": "./cdk.schema.json",
"Resources": {
"Pipeline": {
"Type": "@aws-cdk/aws-codepipeline.Pipeline"
},
"SourceStage": {
"Type": "@aws-cdk/aws-codepipeline.Stage",
"Properties": {
"pipeline": { "Ref": "Pipeline" }
}
},
"Repo": {
"Type": "@aws-cdk/aws-codecommit.Repository",
"Properties": {
"repositoryName": "my-first-decdk-repo"
}
},
"Code": {
"Type": "@aws-cdk/aws-codecommit.PipelineSourceAction",
"Properties": {
"stage": { "Ref": "SourceStage" },
"repository": { "Ref": "Repo" }
}
},
"BuildStage": {
"Type": "@aws-cdk/aws-codepipeline.Stage",
"Properties": {
"pipeline": { "Ref": "Pipeline" }
}
},
"Key": {
"Type": "@aws-cdk/aws-kms.EncryptionKey"
},
"BuildProject": {
"Type": "@aws-cdk/aws-codebuild.PipelineProject",
"Properties": {
"encryptionKey": { "Ref": "Key" }
}
},
"BuildAction": {
"Type": "@aws-cdk/aws-codebuild.PipelineBuildAction",
"Properties": {
"stage": { "Ref": "BuildStage" },
"project": { "Ref": "BuildProject" }
}
}
}
}
35 changes: 35 additions & 0 deletions examples/cdk-examples-declarative/pipeline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
"$schema": "./cdk.schema.json"
Resources:
Pipeline:
Type: "@aws-cdk/aws-codepipeline.Pipeline"
SourceStage:
Type: "@aws-cdk/aws-codepipeline.Stage"
Properties:
pipeline:
Ref: Pipeline
Repo:
Type: "@aws-cdk/aws-codecommit.Repository"
Properties:
repositoryName: my-first-decdk-repo
Code:
Type: "@aws-cdk/aws-codecommit.PipelineSourceAction"
Properties:
stage:
Ref: SourceStage
repository:
Ref: Repo
BuildStage:
Type: "@aws-cdk/aws-codepipeline.Stage"
Properties:
pipeline:
Ref: Pipeline
BuildProject:
Type: "@aws-cdk/aws-codebuild.PipelineProject"
BuildAction:
Type: "@aws-cdk/aws-codebuild.PipelineBuildAction"
Properties:
stage:
Ref: BuildStage
project:
Ref: BuildProject
15 changes: 15 additions & 0 deletions examples/cdk-examples-declarative/queue-kms-example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "./cdk.schema.json",
"Resources": {
"WhatElse": {
"Type": "@aws-cdk/aws-logs.LogGroup"
},
"MyQueue": {
"Type": "@aws-cdk/aws-sqs.Queue",
"Properties": {
"encryption": "Kms",
"fifo": true
}
}
}
}
44 changes: 44 additions & 0 deletions examples/cdk-examples-declarative/sam-api.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"$schema": "./cdk.schema.json",
"Resources": {
"Database": {
"Type": "@aws-cdk/aws-dynamodb.Table",
"Properties": {
"partitionKey": {
"name": "ID",
"type": "String"
}
}
},
"HelloWorldFunction": {
"Type": "@aws-cdk/aws-serverless.Function",
"Properties": {
"codeUri": "src/",
"handler": "app.hello_handler",
"runtime": "python3.6",
"events": {
"Hi": {
"type": "Api",
"properties": {
"path": "/hi",
"method": "get"
}
},
"HiThere": {
"type": "Api",
"properties": {
"path": "/hi/there",
"method": "post"
}
}
}
}
}
},
"Outputs": {
"HelloWorldApi": {
"Description": "API Gateway endpoint URL for Prod stage for Hello World function",
"Value": { "Fn::GetAtt": [ "HelloWorldFunction", "url" ] }
}
}
}
42 changes: 42 additions & 0 deletions examples/cdk-examples-declarative/sam-queue.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"$schema": "./cdk.schema.json",
"Resources": {
"HelloWorldFunction": {
"Type": "@aws-cdk/aws-serverless.Function",
"Properties": {
"codeUri": "src/",
"handler": "app.hello_handler",
"runtime": "python3.6",
"environment": {
"PARAM1": "VALUE"
},
"events": {
"HelloWorld": {
"type": "SQS",
"properties": {
"queueArn": { "Fn::GetAtt": [ "MyQueue", "queueArn" ] },
"batchSize": 10
}
},
"Queue2": {
"type": "SQS",
"properties": {
"queueArn": { "Fn::GetAtt": [ "NonCDKQueue", "Arn" ] },
"batchSize": 10
}
}
}
}
},
"NonCDKQueue": {
"Type": "AWS::SQS::Queue"
},
"MyQueue": {
"Type": "@aws-cdk/aws-sqs.Queue",
"Properties": {
"encryption": "Kms",
"fifo": true
}
}
}
}
2 changes: 2 additions & 0 deletions examples/cdk-examples-declarative/src/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def handler:
print('hi')
7 changes: 7 additions & 0 deletions examples/cdk-examples-declarative/synth
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
if [ ! -f "$1" ]; then
echo "$1 not found"
exit 1
fi
exec cdk synth -a "../../tools/decdk/bin/recdk $1" $2 $3 $4 $5 $6 $7 $8

8 changes: 8 additions & 0 deletions examples/cdk-examples-declarative/vpc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "./cdk.schema.json",
"Resources": {
"VPC": {
"Type": "@aws-cdk/aws-ec2.VpcNetwork"
}
}
}
Loading