Skip to content

Commit

Permalink
feat: no more generated attribute types in CFN layer (L1)
Browse files Browse the repository at this point in the history
Now that we can represent attributes as native strings and string lists,
this covers the majority of resource attributes in CloudFormation.

This change:

* String attributes are represented as `string` (like before).
* String list attribute are now represented as `string[]`.
* Any other attribute types are represented as `cdk.Token`.

Attributes that are represented as Tokens as of this change:

* amazonmq has a bunch of `Integer` attributes (will be solved by #1455)
* iot1click has a bunch of `Boolean` attributes
* cloudformation has a JSON attribute
* That's all.

A few improvements to cfn2ts:

* Auto-detect cfn2ts scope from package.json so it is more self-contained
  and doesn't rely on cdk-build-tools to run.
* Added a "cfn2ts" npm script to all modules so it is now possible
  to regenerate all L1 via "lerna run cfn2ts".
* Removed the premature optimization for avoiding code regeneration
  (it saved about 0.5ms).

Fixes #1406
  • Loading branch information
Elad Ben-Israel committed Jan 7, 2019
1 parent 5b24583 commit bb71567
Show file tree
Hide file tree
Showing 86 changed files with 256 additions and 168 deletions.
16 changes: 16 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,22 @@ Here are a few useful commands:
evaluate only the rule specified [awslint README](./tools/awslint/README.md)
for details on include/exclude rule patterns.

### cfn2ts

This tool is used to generate our low-level CloudFormation resources
(L1/`CfnFoo`). It is executed as part of the build step of all modules in the
AWS Construct Library.

The tool consults the `cdk-build.cloudformation` key in `package.json` to
determine which CloudFormation namespace this library represents (e.g.
`AWS::EC2` is the namespace for `aws-ec2`). We maintain strict 1:1 relationship
between those.

Each module also has an npm script called `cfn2ts`:

* `npm run cfn2ts`: generates L1 for a specific module
* `lerna run cfn2ts`: generates L1 for the entire repo

## Development Workflows

### Full clean build
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/alexa-ask/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"pkglint": "pkglint -f",
"test": "cdk-test",
"watch": "cdk-watch",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "Alexa::ASK"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-amazonmq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"pkglint": "pkglint -f",
"test": "cdk-test",
"watch": "cdk-watch",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::AmazonMQ"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::ApiGateway"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-applicationautoscaling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::ApplicationAutoScaling"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-appstream/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"pkglint": "pkglint -f",
"test": "cdk-test",
"watch": "cdk-watch",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::AppStream"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-appsync/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::AppSync"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-athena/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"keywords": [
"aws",
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-autoscaling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::AutoScaling"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-autoscalingplans/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::AutoScalingPlans"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-batch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::Batch"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-budgets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::Budgets"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-certificatemanager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::CertificateManager"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-cloud9/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::Cloud9"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-cloudformation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::CloudFormation"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-cloudfront/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::CloudFront"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-cloudtrail/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"test": "cdk-test",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::CloudTrail"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-cloudwatch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::CloudWatch"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-codebuild/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::CodeBuild"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-codecommit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::CodeCommit"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-codedeploy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::CodeDeploy"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-codepipeline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::CodePipeline"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-cognito/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::Cognito"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::Config"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-datapipeline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::DataPipeline"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-dax/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::DAX"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-directoryservice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::DirectoryService"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-dlm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"pkglint": "pkglint -f",
"test": "cdk-test",
"watch": "cdk-watch",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::DLM"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-dms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::DMS"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-dynamodb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::DynamoDB"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-ec2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::EC2"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-ecr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::ECR"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-ecs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::ECS"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-efs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::EFS"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-eks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::EKS"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-elasticache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::ElastiCache"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-elasticbeanstalk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::ElasticBeanstalk"
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-elasticloadbalancing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint"
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts"
},
"cdk-build": {
"cloudformation": "AWS::ElasticLoadBalancing"
Expand Down
Loading

0 comments on commit bb71567

Please sign in to comment.