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

Updating to master #1

Merged
merged 292 commits into from
Jan 6, 2020
Merged

Updating to master #1

merged 292 commits into from
Jan 6, 2020

Conversation

KingOfPoptart
Copy link
Owner


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

Elad Ben-Israel and others added 30 commits November 11, 2019 11:41
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.
…4975)

We used to scope the permission for calling it from CloudWatch Logs
under the Lambda. However, when it was used multiple times there
would be a name conflict.

Instead, scope the Permission under the SubscriptionFilter.

Fixes #4951.
Add a bunch of skelaton handlers in Python to make it a little easier to get started and see what it takes to write a handler.
Also, remove the TOC which is not formatted well in our reference documentation.
…4998)

Legacy mode for #4895 still used the uniquely generated id instead of the stack name as the artifact ID in the cloud assembly. The implications were that even if users were not opted-in to the new behavior (through the feature flag), they could not use the stack name in the CLI because the stack artifact ID was still new.

This fix ensures that if the feature flag is not enabled, the artifact ID itself uses the stack name, hence allowing users to query by stack name as long as they are not opted in to the new behavior.

Fixes #4997
…geSet should be executed (#4852)

* feat(aws-cdk): adding new option to `cdk deploy`

I created the option to *NOT* execute the ChangeSet via `cdk deploy`.

The flag is called **execute** and by default is set to true. By not providing this flag, the workflow of `cdk deploy` will be the same.

If anyone wants to *NOT* execute the ChangeSet, providing the flag `--no-execute` will pass the execution of the ChangeSet.

You will be able to see the ChangeSet in AWS CloudFormation Console, validate the resources and discard or execute the ChangeSet.

closes #4739

* feat(cli): adding new option to `cdk deploy` to indicate whether ChangeSet should be executed

I created the option to *NOT* execute the ChangeSet via `cdk deploy`.

The flag is called **execute** and by default is set to true. By not providing this flag, the workflow of `cdk deploy` will be the same.

If anyone wants to *NOT* execute the ChangeSet, providing the flag `--no-execute` will pass the execution of the ChangeSet.

You will be able to see the ChangeSet in AWS CloudFormation Console, validate the resources and discard or execute the ChangeSet.

closes #4739

* feat(cli): adding new option to `cdk deploy` to indicate whether ChangeSet should be executed

I created the option to *NOT* execute the ChangeSet via `cdk deploy`.

The flag is called **execute** and by default is set to true. By not providing this flag, the workflow of `cdk deploy` will be the same.

If anyone wants to *NOT* execute the ChangeSet, providing the flag `--no-execute` will pass the execution of the ChangeSet.

You will be able to see the ChangeSet in AWS CloudFormation Console, validate the resources and discard or execute the ChangeSet.

closes #4739

* feat(cli): adding new option to `cdk deploy` to indicate whether ChangeSet should be executed

I created the option to *NOT* execute the ChangeSet via `cdk deploy`.

The flag is called **execute** and by default is set to true. By not providing this flag, the workflow of `cdk deploy` will be the same.

If anyone wants to *NOT* execute the ChangeSet, providing the flag `--no-execute` will pass the execution of the ChangeSet.

You will be able to see the ChangeSet in AWS CloudFormation Console, validate the resources and discard or execute the ChangeSet.

closes #4739

* feat(cli): adding new option to `cdk deploy` to indicate whether ChangeSet should be executed

I created the option to *NOT* execute the ChangeSet via `cdk deploy`.

The flag is called **execute** and by default is set to true. By not providing this flag, the workflow of `cdk deploy` will be the same.

If anyone wants to *NOT* execute the ChangeSet, providing the flag `--no-execute` will pass the execution of the ChangeSet.

You will be able to see the ChangeSet in AWS CloudFormation Console, validate the resources and discard or execute the ChangeSet.

closes #4739

* feat(cli): adding new option to `cdk deploy` to indicate whether ChangeSet should be executed

I created the option to *NOT* execute the ChangeSet via `cdk deploy`.

The flag is called **execute** and by default is set to true. By not providing this flag, the workflow of `cdk deploy` will be the same.

If anyone wants to *NOT* execute the ChangeSet, providing the flag `--no-execute` will pass the execution of the ChangeSet.

You will be able to see the ChangeSet in AWS CloudFormation Console, validate the resources and discard or execute the ChangeSet.

closes #4739
* chore(core): resolve tokens before publishing tree.json

* try-catchall block

* Rename getAttributes() to synthAttributes()

* Continue rendering the tree on errors

* Fixed up a length bug + test
…5022)

This reverts commit b7b4336.

This is being reverted as it introduced a regression in assets that contain symlinks during cdk synth.
Fixes #4978
…#5031)

* **New Resource Types**

  * `AWS::CodeStarNotifications::NotificationRule`
  * `AWS::MediaConvert::JobTemplate`
  * `AWS::MediaConvert::Preset`
  * `AWS::MediaConvert::Queue`

* **Property Changes**

  * `AWS::AppStream::ImageBuilder` `AccessEndpoints` (__added__)
  * `AWS::AppStream::Stack` `AccessEndpoints` (__added__)
  * `AWS::AppStream::Stack` `EmbedHostDomains` (__added__)

* **Property Type Changes**

  * `AWS::DLM::LifecyclePolicy.FastRestoreRule` (__removed__)
  * `AWS::AppStream::ImageBuilder.AccessEndpoint` (__added__)
  * `AWS::AppStream::Stack.AccessEndpoint` (__added__)
  * `AWS::DLM::LifecyclePolicy.Schedule` `FastRestoreRule` (__deleted__)
  * `AWS::ECS::TaskDefinition.InferenceAccelerator` `DevicePolicy` (__deleted__)
Elad Ben-Israel and others added 28 commits January 1, 2020 09:12
* fix(eks): generated cluster name can exceed 63 characters

Since the generated cluster name includes the logical ID of the resource as a prefix with a postfix of the request ID, the resulting generated name can exceed 63 characters.

Fixes #5596

NOTE: since the current version of the EKS module have not been released yet, this is not a breaking change.

* add test for cluster name trimming

* reduce to 62 because error message is not clear

* update to 100 chars

* update expectations
* feat(apigateway): L2 support for lambda token authorizers

* Address PR comments

* More PR feedback

* Restructure binding

* Restructuring classes to allow for Authorizer.token() and Authorizer.iam() experience

* PR feedback

* Authorizer -> Authorization
* drop using Physical Name

* Switch to eslint recommended import style

* chore: proposed refactor for authorizers design (#5584)

* simplify authorizers class design

- rename `AuthorizerBase` to `Authorizer`. This class should actually have the `CfnAuthorizer` instantiation, but will only be introduced when an additional authorizer is included.
- simplify `AuthorizerBase` dramatically
- move logic to cache `restApiId` from `AuthorizerBase` to `TokenAuthorizer`. When an additional authorizer is added, we will refactor.
- remove the usage `Authorizer.token`. It is non-idiomatic in this context since we support one authorizer reused multiple times.

* moved Authorizer to authorizer.ts

* fix broken references and types

Co-authored-by: Niranjan Jayakar <16217941+nija-at@users.noreply.github.com>

* Documentation updates & PR feedback

Co-authored-by: Elad Ben-Israel <benisrae@amazon.com>
* fix(core): Support tags for Cognito User Pools

 * moved all knowledge about tag names into the schema package and
 included UserPoolTags as taggable name
 * refactored codegen to use new schema package to identify tag
 properties

BREAKING CHANGE:
 * TagManager constructor now takes a property object instead of
 individual agruments: new TagManager(props: TagManagerProps) instead of new cdk.TagManager(cdk.TagType.STANDARD, resourceType, initialTags);

Fixes #3882

* moving back to non-breaking change and simplifying the interface/type checking

* fixing logic gap in tag type lookup

* Update tag-manager.ts

* Update tag-manager.ts

* cleaning up final comments

* refactor(core): create asCfnProperty on TagManager to support tag property names besides tags

* Update packages/@aws-cdk/core/lib/tag-manager.ts

Co-Authored-By: Elad Ben-Israel <benisrae@amazon.com>

* Update packages/@aws-cdk/core/lib/tag-manager.ts

Co-Authored-By: Elad Ben-Israel <benisrae@amazon.com>

* refactor(core): remove asCfnProperty from tag-manager and put the logic in cfn-resource

* Update cfn-resource.ts

* refactor(core): clean up cfnProperties to ensure undefined returns {}

Co-authored-by: Elad Ben-Israel <benisrae@amazon.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
The README incorrectly used `lambda.TokenAuthorizer` in the Lambda-based
token authorizer example

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* chore(eks): kubectl resource provider

Merge the `Helm` and `KubernetesResource` providers into a single "KubectlProvider" which uses the resource type to decide which actual provider will be used. This is in order to reduce the footprint of this module and since we will need to introduce an additional provider in order to support Fargate Profiles.

* update unit test expectations

* update test expectations
Add support for `MathExpression`, which is a new class that can be used
in place of `Metric` objects in graphs and alarms.

Also in this commit, make it very clear what the purpose of the `unit`
property is, and deprecate `toGraphConfig()` and `toAlarmConfig()`.

Fixes #1077, fixes #5449, fixes #5261, fixes #4716.
fixes #5592

Co-authored-by: Elad Ben-Israel <benisrae@amazon.com>
Report missing context when context is not available.
Prior to this change the synthesize method return before reporting missing context when invoked on a nested stacks.
fixes #5594
Add support for `--up` in `foreach.sh` which will execute the command for the current module and all its dependencies (instead of the entire repo).

Use this new feature in `buildup` so from now, `buildup` is resumable. Restart can be done through `./buildup --restart`.

Update CONTRIBUTING guide.
* support custom docker files

* revert tsconfig changes

* doc strings modification according to conventions
Using the new "rosetta" sample compiler from aws/jsii#925, introduce
fixtures and fix up sample code to make all examples in the `aws-ec2`
package compile.

This serves as a demonstration of how to set up fixtures and how
to write the examples.

Need to reverse the order between `@example` and `@attribute`; because 
of a bug in the TypeScript compiler, it will think a new tag starts if
a `@` comes up in the example. This means that we cannot type
`import s3 = require('@aws-cdk/aws-s3');` in examples (it would parse `@aws = -cdk/aws-s3');`.

To fix that, we absorb non-recognized tags that follow an `@example` 
back into the example body, but since `@attribute` is non-recognized, 
we'd absorb that as well. The solution is to have `@example` as the last tag.

----

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

<!-- 
Please read the contribution guidelines and follow the pull-request checklist:
https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md
 -->
Add `blockDevice` property to EC2 `Instance`, based on `aws-autoscaling`s previous implementation.

We can't unify the two implementations, as that will break API compatibility. Hence, the two libraries have different types for specifying block devices.

Continuation of old PR by @nmussy  for which the source branch has disappeared.

Fixes #4773, closes #4781.
There is some interesting magic happening around the runtime-info
module: `jest` replaces the standard `require` function so it can honor
module mocking requirements, however this does (intentionally) not
implement `require.cache`, which is used to determine which CDK
libraries are loaded during a particular execution (in order to populate
the `AWS::CDK::Metadata` resource as needed).

In order to work around this, the `require.cache` reading was indirected
through a proxy module, so it can be stubbed, too, with a pretend cache
content, in order to make the test still workable.
* fix(eks): aws-auth username not set by default

When mapping roles and users through the aws-auth config map, if a username is not specified, we need to default to the user/role ARN. Not specifying a default username will cause things like metrics server to fail.

Fixes #5263

* chore(build): foreach.sh --up

Add support for `--up` in `foreach.sh` which will execute the command for the current module and all its dependencies (instead of the entire repo).
Use this new feature in `buildup` so from now, `buildup` is resumable. Restart can be done through `./buildup --restart`.

Update CONTRIBUTING guide.

* update expectations
…urce (#5658)

60 seconds turns out to be a bit on the short side when installing the latest SDK.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…ern (#5651)

* fix(eks): default capacity uses desiredCapacity which is an anti-pattern

As described in #5215, `desiredCapacity` is not the recommended way to configure an auto scaling group since it will cause the ASG to reset the number of nodes in every CloudFormation deployment. Since EKS's default capacity uses `desiredCapacity` instead of `minCapacity`, as of #5507 this would emit a warning: "desiredCapacity has been configured. Be aware this will reset the size of your AutoScalingGroup on every deployment".

This change modifies the behavior of the default capacity such that it will configure the ASG using `minCapacity` instead of `desiredCapacity` as recommended by ASG.

Fixes #5650

* Update integ.eks-cluster.defaults.expected.json

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
`Metric` objects always could have `region` and `account` fields, but it
was the user's responsibility to set them. They can now automatically
copy the `region` and `account` fields from a Construct anywhere in the
Construct tree (under a `Stack`) by calling the `attachTo()` method.

Predefined `Metric` objects returned by `.metricsXxx()` functions of the
AWS Construct Library will automatically have the scope of the
originating construct attached.

In this way, cross-environment dashboards can automatically be created.
Immutably imported `Role`s could not be used for CodeBuild
`Project`s, because they would create a policy but be unable
to attach it to the Role. That leaves an unattached Policy,
which is invalid.

Fix this by making `Policy` objects only render to an `AWS::IAM::Policy`
resource if they actually have any effect. It is perfectly allowed to
create new unattached Policy objects, or have empty Policy objects.
Only if and when they actually need to mutate the policy of an IAM
identity will they render themselves to the CloudFormation template.
Being able to abstract away these kinds of concerns is exactly the value
of a higher-level programming model.

To allow for the rare cases where an empty Policy object would be
considered a programming error, we still have the flag `mustCreate`
which triggers the legacy behavior of alwyas creating the
`AWS::IAM::Policy` resource which must have a statement and be
attached to an identity.

Fixes #1408.

----

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

<!-- 
Please read the contribution guidelines and follow the pull-request checklist:
https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md
 -->
@KingOfPoptart KingOfPoptart merged commit f5d3ab8 into KingOfPoptart:master Jan 6, 2020
KingOfPoptart added a commit that referenced this pull request Jan 6, 2020
Merge pull request #1 from aws/master
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.