Skip to content

Conversation

@robertma96
Copy link
Owner


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

corydozen and others added 30 commits November 5, 2019 08:35
I found two instances of wrong enums
…path notation (#4842)

* fix(ssm): malformed ARNs for parameters with physical names that use path notation

SSM parameter names can have one of two forms: “simpleName” or “/path/name”. This makes it tricky to render an ARN for the parameter is the name is an unresolvable token (such as a “Ref”) because we can’t decide whether a “/“ separator is required in the ARN. The previous implementation assumed "Ref" always returns the name without a "/" prefix, and therefore did not use the "/" separator. This fix will use the physical name itself (if possible) to determine the separator (and also assume that generated names will not use the path notation).

The only case where this is impossible is if the physical name is a token (either created or imported), in which case we should be able to synthesize a CloudFormation condition which will parse the token during deployment.

This test also adds a validation that verifies that if a physical name is provided and uses path notation, it must begin with a "/".

Misc: re-add `install.sh` to call `npx yarn install`

* explicit parameterArnSeparator

revert attempt to guess parameter name prefix if it's a token since we can't incorporate refs in conditions. Instead, if the parameter name
if a token, we expect `parameterArnSeparator` to be explicitly defined and be one of "/" or "".

* misc

* fix test expectation
* add public API doc

* add --frozen-lockfile to install.sh

* rename "parameterArnSeparator: string" to "simpleName: boolean"
* feat(cfnspec): update CloudFormation spec to 7.3.0

* Update expectations

* Update more expectations
The Role ARN should not contain the region, as the 'iam' service
is region-independent.
…esource dependencies

The DynamoDB global table construct was incorrectly declaring its dependencies,
having the coordinator stack depend on the resources in the table stacks,
instead of on the stacks themselves.
That resulted in resources in the coordinator stack depending on the global tables,
which cannot work, as those are from different stacks.
Changed the logic to declare dependencies between the stacks explicitly.

Fixes #4676
It was missing a default label assignment and was hence invalid.
Also removed prohibition to consider newer `@types/nodes` versions (will handle through dependabot messages).
* feat(cfnspec): update CloudFormation spec to 7.3.0

* feat(events): support event bus for rule

Adds an `eventBus` prop to the `Rule` construct.
* feat(custom-resources): async custom resources

`AsyncCustomResource` is a framework for defining robust custom resources. It makes it easy to implement providers for resources that require waiting for the resource to be ready, potentially for time period longer than the AWS Lambda timeout (15min at the moment). When a resource is created, the "begin" operation is invoked, and a state machine is triggered to wait for "complete" to indicate that it's done. It can also indicate that it's still waiting, in which case, Step Functions retry logic will kick in and "complete" will be called thereafter. If retries are exhausted, the resource operation will fail with a timeout. Any exceptions thrown from "begin" or "complete" will be reported as an operation failure to ensure that the custom resource does not hang the stack operation.

* misc

- change semantics to "onEvent" and "isComplete"
- use Lambda layers to load user code
- reorg project files

* move aws-custom-resource to a subdirectory (both lib/ and test/)

* good test coverage for async custom resource runtime handler

* misc

* support specifying execution role for each resource instance (very powerful)
* always require that on-event will return a physical resource id (to avoid errors)
* emit entire stack trace on errors
* implement an integration test/sample (S3File)

* add failing test

* remove support for resource-specific roles

* extract user handlers to separate lambdas, which means we are now language agnostic!

* Misc

* use RequestId as the name of the state machine execution due to limitations in the name
* make handler names required to make sure users are aware that they have to implement them
* implement another custom resource in the integration test which "waits" for the object to contain certain contents (tests async resources).

* rename to ProviderFramework and add README

* add types.d

* a bunch of minor fixes

* chore(custom-resources): reorg and migreate to jest

As a preparation for adding the custom resource provider framework (#4572), which includes multiple files and tests, reorg the file structure of this module such that all files
related to the `AwsCustomResource` construct will be under `lib/aws-custom-resource` and `test/aws-custom-resource`.

Also, migrate all unit tests from nodeunit to jest.

* Delete sdk-api-metadata.json

* Update packages/@aws-cdk/custom-resources/lib/provider-framework/provider.ts

Co-Authored-By: Jonathan Goldwasser <[email protected]>

* Update packages/@aws-cdk/custom-resources/README.md

Co-Authored-By: Jonathan Goldwasser <[email protected]>

* Update packages/@aws-cdk/custom-resources/README.md

Co-Authored-By: Jonathan Goldwasser <[email protected]>

* Apply suggestions from code review

Co-Authored-By: Jonathan Goldwasser <[email protected]>

* add sdk-json to .gitignore

* user-defined handlers are now passed as lambda.IFunction and make isComplete optional

Instead of presuming to define the AWS Lambda function on behalf of the user, we now simply ask the user to supply a couple of IFunction objects. This gives users maximum flexibility in configuring their AWS Lambda environments.

Furthermore, this change also makes isComplete optional and only defines the waiter resources in case isComplete is provided.

Refactored integ test so that providers are deployed as a separate stack and their entrypoints are exported through CFN export names.

* stop calling isComplete synchronously

Since we now have a better way to represent that onEvent is synchronous (by simply not supplying an isComplete handler), and this will also result in a cleaner stack (no step functions, etc), the value of calling isComplete synchronously has been reduced. Combined with the observation by @jogold that the framework onEvent timeout would have to be user onEvent+isComplete, the complexity is not worth it.

Also, refactor unit test harness such that it simulates the entire workflow (incl. reaction to startExecution and simulation of the waiter step function).

* allow extensibility for CustomResourceProvider

accept an interface instead of a class and use the `bind` pattern to allow defining resources as part of the provider.

* simplify integration test (a single stack)

* update README

* code review fixes

- remove validation of CFN event (not required)
- redesign `failOnError` as `safeHandler` which returns a "safe" cloudformation handler.
- fail if user handler returns a non-JSON response.

* fix docstring in aws-cloudformation

* set all framework timeouts to 15min

later on we can figure out something smarter if need be

* add a section about error handling

* pass modules in topological order during packaging
We use the `@default` annotation to tell people about default
values/behaviors if they leave out a particular property.

Some contributors think we mean "literally describe what the value
of the property is if it's not specified" and put in `@default
undefined`, which is technically true but not very helpful.

Add an awslint rule which disallows this.
* chore: "compat" script for api compatibility check

Add a `compat` script to all modules and to the repo root which runs api compatibility checks.
Also add a section in the contribution guide that explains about api checks.

Add a "build" and "pack" scripts in the root package.json so users can just run "yarn build/pack" from the root.

* cr tweaks
…cation load balanced services (#4825)

* - feat(ecs-patterns): allow to specify different NLB listener port other than the default 80(fix #4793)
- feat(ecs-patterns): public facing NLB fronted fargate tasks with assignPublicIp enabled should allow all ipv4 traffic to the ingress port on the fargate task

* - support ApplicationLoadBalancedServiceBase as well
- remove non-related logic to another PR

* minor fix

* minor fix

* minor fix

* add the testing

* add more tests:

✔ setting NLB special listener port to create the listener
✔ setting ALB special listener port to create the listener
✔ setting ALB HTTPS protocol to create the listener on 443
✔ setting ALB HTTP protocol to create the listener on 80
✔ setting ALB without any protocol or listenerPort to create the listener on 80

* minor lint fix

* minor fix
…4849)

* feat(apigateway): allow customizing the name of the CfnOutput

* chore(apigateway): refactor endpointExportName resolution logic

* chore(apigateway): fix tests for restapi

* simplify logic a little
* feat(core): yarn global detection

* feat(core): package-manager option

* feat: generate-only, revert previous work

* chore: cleaner canUseNetwork default value

* fix: missing refactor

* chore: update generate-only description

* fix: do not run postInstall if generateOnly

* fix: do not run initializeGitRepository if generateOnly

* fix: add generateOnly to settings list

* trigger a build

* remove trailing whitespace
* added yarn

* verify that gpg key
* feat(toolkit): configure image scanning on push

Amazon ECR image scanning helps in identifying software vulnerabilities in container images.
Amazon ECR uses the Common Vulnerabilities and Exposures (CVEs) database from the open source
CoreOS Clair project and provides a list of scan findings.

This feature is available at no additional charge.

* dummy change to trigger build
Currently, the message generated is 'lerna ERR! yarn run build exited 2'
which is not very helpful.
…dpoints (#4908)

Support a `securityGroups` prop for interface VPC endpoints in a non breaking way.

Clarify documentation on interface VPC endpoints connections.

Add missing Storage Gateway.

Closes #4589
Closes #2699
Closes #3446
Fixes remaining issues with .NET CDK.
dependabot-preview bot and others added 29 commits November 8, 2019 13:44
* chore: checkfiles with yarn install

* use .yarnrc configuration instead
This was a leftover from previous stages and should not be published (it
has no artifacts anyway and is just a tooling artifact).
* fix(apigateway): allow multiple api keys to the same usage plan

fixes #4860

* Updated to not change physical ids on existing UsagePlanKey

* Changed to use uniqueId
…4909)

* feat(custom-resources): allow specifying role for AwsCustomResource

Also removed console.log outputs from tests

Closes #4906

* update doc for role
Use the 'region' property on subscribing to imported SNS topics so that
the user can avail cross-region subscriptions.

fixes #3842
- NODE_VERSION bump to 10.17.0(LTS)
Add support for NAT instances (as opposed to NAT gateways) on VPCs. This
change introduces the concept of a 'NAT provider', and provides two
implementations out of the box: one for gateways, one for instances.

Instances are not guarded against termination; a future implementation
should use ASGs to make sure there are always instances running.

To make it easier to pick the right AMI for the NAT instance,
add an AMI context provider, which will look up AMIs available to
the user.

Fixes #4876.
…tructs to tree.json (#4894)

Modifies the children node from an array to an object with each child object keyed on its id. Also added an interface `IInspectable` that constructs can optionally implement to contribute attributes into `tree.json`.

Generated classes for Cfn resources implement `IInspectable` and contribute their resource type and props in the attribute bag.

Supercedes #4562
Design proposal for a pattern/mechanism that will allow us to introduce
breaking capabilities which will only be applied to new projects created
by "cdk init" and won't break old projects without explicit action from the user.
Since it is very common for users to need to reference local files using `path.join` and `__dirname`, it is only pragmatic that we will include @types/node in the init template.

We use a pinned version since experience shows that these types can get a bit messed up (see #3839)

Supersedes #4462
Reverts #3840
…feature flag) (#4895)

Since we used the stack name as the template file name, if users wanted to use the same stack name in two environments, the emitted templates overwrote each other.

Furthermore, the CLI used the artifact ID as the stack name, so this became a bit more complex. This means that `assembly.getStack()` is now ambiguous, so I renamed it `getStackByName` which fails if there are two stacks with the same name (legitimate) and added `getStackArtifact` which uses the artifact ID.

The core library will effectively generate identical cloud assemblies if the stack name and artifact IDs are the same, and to ensure backwards compat, no existing tests have been changed (albeit it would have been more correct to replace all `getStackByName` with `getStackArtifact`, but effectively this is the same thing if they are equal).

We want the template file name to use the artifact ID instead of the physical stack name but this can break users that depend on this behaviour (despite the fact that it's a formal API). To avoid this, we will only enable this new behaviour behind a [feature flag](#4925) which means that it will only be enabled for new projects created through `cdk init`, but old projects will still get the old behaviour.

RFC for feature flags: #4925

Fixes #4412

BREAKING CHANGE: template file names in `cdk.out` for new projects created by `cdk init` will use `stack.artifactId` instead of the physical stack name to enable multiple stacks to use the same name. In most cases the artifact ID is the same as the stack name. To enable this fix for old projects, add the context key `@aws-cdk/core:enableStackNameDuplicates: true` in your `cdk.json` file.
)

* Add cloudmap namespace as a property of cloudmap options

* Address pr feedback

* Address feedback
Without it the bin is not hoisted to `node_modules/.bin` and cannot be called from
individual package directories.
Fix the Mergify operator for author condition.

The current value for `author` is meant to be a regexp so the `~=` operator must be used to match it, not just `=`.
…framework) (#4946)

In order to make it easier to get started and implement custom resources that do not require changes to physical resource IDs, the provider framework now allows `onEvent` to omit the `PhysicalResourceId` return value.

For `CREATE` operations, it will default to the `RequestId`. For `UPDATE` and `DELETE` it will return the current `PhysicalResourceId`.

Misc: in aws-custom-resource, use `fs.readFileSync(__dirname)` instead of `require` to load `sdk-api-metadata.json`, so that the typescript compiler won't yell that this file is not defined in  tsconfig.json.
@types/node version was posing problems with recent TypeScript versions
and needed to be upgraded. Also upgraded other dependencies to the correct
latest versions.
@robertma96 robertma96 merged commit 3e9ebdc into robertma96:master Nov 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.