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(core): Add construct.node.stack attribute #1753

Merged
merged 3 commits into from
Feb 13, 2019

Conversation

RomainMuller
Copy link
Contributor

@RomainMuller RomainMuller commented Feb 13, 2019

Makes it easier to access some construct's Stack, avoiding
having to sprinkle Stack.find(this) everywhere.

BREAKING CHANGE: Stack.find(c) and Stack.tryFind(c) were
replaced by c.node.stack.

Fixes #798


Pull Request Checklist

  • Testing
    • Unit test added
    • CLI change?: coordinate update of integration tests with team
    • cdk-init template change?: coordinated update of integration tests with team
  • Docs
    • jsdocs: All public APIs documented
    • README: README and/or documentation topic updated
  • Title and Description
    • Change type: title prefixed with fix, feat will appear in changelog
    • Title: use lower-case and doesn't end with a period
    • Breaking?: last paragraph: "BREAKING CHANGE: <describe what changed + link for details>"
    • Issues: Indicate issues fixed via: "Fixes #xxx" or "Closes #xxx"
  • Sensitive Modules (requires 2 PR approvers)
    • IAM Policy Document (in @aws-cdk/aws-iam)
    • EC2 Security Groups and ACLs (in @aws-cdk/aws-ec2)
    • Grant APIs (only if not based on official documentation with a reference)

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

Makes it easier to access some construct's `Stack`, avoiding
having to sprinkle `Stack.find(this)` everywhere. While there,
added `construct.node.formatArn` and `construct.node.parseArn`
as convenience methods to avoid indirecting via the `Stack`.

BREAKING CHANGE: `Stack.find(c)` and `Stack.tryFind(c)` were
replaced by `c.node.stack`.

Fixes #798
@RomainMuller RomainMuller requested review from skinny85, SoManyHs and a team as code owners February 13, 2019 14:59
Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I like the formatArn/parseArn sugar... Why not mirror all of the Stack API then into node? I'd argue that stack.region and stack.account are way more prevalent than formatArn, but then where do you stop?

It also doesn't make sense when you read the code this.node.formatArn...

@RomainMuller
Copy link
Contributor Author

I had mixed feelings about those two sugars (they save a meager 5 characters, but on the other hand those were annoying to industrially type around :D). Removed those - this PR is now a Diet PR (the same great taste, one third of the sugar).

@RomainMuller RomainMuller added pr/breaking-change This PR is a breaking change. It needs to be modified to be allowed in the current major version. @aws-cdk/core Related to core CDK functionality labels Feb 13, 2019
@RomainMuller RomainMuller merged commit a46cfd8 into master Feb 13, 2019
@RomainMuller RomainMuller deleted the rmuller/add-construct-node-stack branch February 13, 2019 16:04
@NGL321 NGL321 added the contribution/core This is a PR that came from AWS. label Sep 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/core Related to core CDK functionality contribution/core This is a PR that came from AWS. pr/breaking-change This PR is a breaking change. It needs to be modified to be allowed in the current major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider making Construct stack-aware
3 participants