-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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(core): environment-agnostic cloud assemblies #2922
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Formalize the simple use case for synthesizing cloudformation templates that are not pre-associated with a specific AWS account/region. When a CDK stack is defined without an explicit `env` configuration, or if `env.account` and/or `env.region` are set to `Aws.accountId`/`Aws.region`, the stack is said to be "environment-agnostic". This means that when a template is synthesized, we will use the CloudFormation intrinsics `AWS::AccountId` and `AWS::Region` instead of concrete account/region. The cloud assembly manifest for such stacks will indicate `aws://unknown-account/unknown-region` to represent that this stack is environment-agnostic, and tooling should rely on external configuration to determine the deployment environment. Environment-agnostic stacks have limitations. For example, their resources cannot be referenced across accounts or regions, and context providers such as SSM, AZs, VPC and Route53 lookup cannot be used since they won't know which environment to query. To faciliate the env-agnostic use case at the AWS Construct Library level, this change removes any dependency on concrete environment specification. Namely: - The AZ provider, which is now accessible through `stack.availabilityZones` will fall back to use `[ Fn::GetAZs[0], Fn::GetAZs[1] ]` in case the stack is env-agnostic. This is a safe fallback since all AWS regions have at least two AZs. - The use of the SSM context provider by the EC2 and ECS libraries to retrieve AMIs was replaced by deploy-time resolution of SSM parameters, so no fallback is required. See list of breaking API changes below. Added a few static methods to `ssm.StringParameter` to make it easier to reference values directly: * `valueFromLookup` will read a value during synthesis using the SSM context provider. * `valueForStringParameter` will return a deploy-time resolved value. * `valueForSecureStringParameter` will return a deploy-time resolved secure string value. Fixes #2866 BREAKING CHANGE: `ContextProvider` is no longer designed to be extended. Use `ContextProvider.getValue` and `ContextProvider.getKey` as utilities. * **core:** `Context.getSsmParameter` has been removed. Use `ssm.StringParameter.valueFromLookup` * **core:** `Context.getAvailabilityZones` has been removed. Use `stack.availabilityZones` * **core:** `Context.getDefaultAccount` and `getDefaultRegion` have been removed an no longer available. * **route52:** `HostedZoneProvider` has been removed. Use `HostedZone.fromLookup`. * **ec2:** `VpcNetworkProvider` has been removed. Use `Vpc.fromLookup`. * **ec2:** `ec2.MachineImage` will now resolve AMIs from SSM during deployment. * **ecs:** `ecs.EcsOptimizedAmi` will now resolve AMis from SSM during deployment.
rix0rrr
reviewed
Jun 19, 2019
…rough env variables
eladb
commented
Jun 19, 2019
@@ -58,6 +58,7 @@ class Test extends cdk.Stack { | |||
name: 'Basic', | |||
apiKey: key, | |||
description: 'Free tier monthly usage plan', | |||
throttle: { rateLimit: 5 }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually required
rix0rrr
approved these changes
Jun 19, 2019
eladb
pushed a commit
that referenced
this pull request
Jun 20, 2019
following up on #2922, manifest may include "env" that indicates unknown-account/unknown-region, which will cause old CLIs to fail, so we must bump the version to ensure compatibility. BREAKING CHANGE: Previous versions of the CDK CLI will not be fully compatible with this version of the framework and vice versa.
eladb
pushed a commit
that referenced
this pull request
Jun 23, 2019
following up on #2922, manifest may include "env" that indicates unknown-account/unknown-region, which will cause old CLIs to fail, so we must bump the version to ensure compatibility. BREAKING CHANGE: Previous versions of the CDK CLI will not be fully compatible with this version of the framework and vice versa.
1 task
5 tasks
5 tasks
Closed
5 tasks
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
This was referenced Dec 12, 2019
This was referenced Jan 20, 2020
7 tasks
This was referenced Sep 24, 2024
Open
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Formalize the simple use case for synthesizing cloudformation templates that are not pre-associated with a specific AWS account/region.
When a CDK stack is defined without an explicit
env
configuration, or ifenv.account
and/orenv.region
are set toAws.accountId
/Aws.region
, the stack is said to be "environment-agnostic". This means that when a template is synthesized, we will use the CloudFormation intrinsicsAWS::AccountId
andAWS::Region
instead of concrete account/region.The cloud assembly manifest for such stacks will indicate
aws://unknown-account/unknown region
to represent that this stack is environment-agnostic, and tooling should rely on external configuration to determine the deployment environment.Environment-agnostic stacks have limitations. For example, their resources cannot be referenced across accounts or regions, and context providers such as SSM, AZs, VPC and Route53 lookup cannot be used since they won't know which environment to query.
To faciliate the env-agnostic use case at the AWS Construct Library level, this change removes any dependency on concrete environment specification. Namely:
stack.availabilityZones
will fall back to use[ Fn::GetAZs[0], Fn::GetAZs[1] ]
in case the stack is env-agnostic. This is a safe fallback since all AWS regions have at least two AZs.See list of breaking API changes below.
Added a few static methods to
ssm.StringParameter
to make it easier to reference values directly:valueFromLookup
will read a value during synthesis using the SSM context provider.valueForStringParameter
will return a deploy-time resolved value.valueForSecureStringParameter
will return a deploy-time resolved secure string value.Fixes #2866
BREAKING CHANGE:
ContextProvider
is no longer designed to be extended. UseContextProvider.getValue
andContextProvider.getKey
as utilities.Context.getSsmParameter
has been removed. Usessm.StringParameter.valueFromLookup
Context.getAvailabilityZones
has been removed. Usestack.availabilityZones
Context.getDefaultAccount
andgetDefaultRegion
have been removed an no longer available.HostedZoneProvider
has been removed. UseHostedZone.fromLookup
.VpcNetworkProvider
has been removed. UseVpc.fromLookup
.ec2.MachineImage
will now resolve AMIs from SSM during deployment.ecs.EcsOptimizedAmi
will now resolve AMis from SSM during deployment.TODO:
unknown-xxx
in CLIPull Request Checklist
design
folderBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.