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: physical names in the entire Construct Library #2878

Merged
merged 56 commits into from
Jun 17, 2019

Conversation

skinny85
Copy link
Contributor

This PR changes the xyzName attribute of all Resources in the Construct Library to be of type PhysicalName,
and adds an AWS linter rule that checks ensures conformance.

The name of the property can be any ending substring of the base name of the class with the Name
suffix - for example, if my resource is AwesomeFoobar, the name can be foobarName or awesomeFoobarName (that's because we often have Specialized1AwesomeFoobar and Specialized2AwesomeFoobar in our library, that share a base prop interface).

There were a few interesting cases in the library which I didn't change, as I wasn't sure of the semantics of the resources, or they would require class name changes. Would appreciate some guidance there. These were:

  • @aws-kms: AliasProps.name
  • @aws-ssm: ParameterOptions.name
  • @aws-applicationautoscaling: ScalableTargetProps.resourceId
  • @aws-route53: CommonHostedZoneProps.zoneName
  • @aws-route53: RecordSetOptions.recordName
  • @aws-apigateway: StageProps.stageName
  • @aws-servicediscovery: BaseNamespaceProps.name
  • @aws-config: CustomRuleProps.ruleName
  • @aws-config: ManagedRuleProps.ruleName
  • @aws-config: AccessKeysRotatedProps.ruleName
  • @aws-config: CloudFormationStackNotificationCheckProps.ruleName
  • @aws-config: CloudFormationStackDriftDetectionCheckProps.ruleName
  • @aws-rds: DatabaseClusterProps.databaseName / clusterIdentifier
  • @aws-rds: DatabaseInstanceSourceProps.databaseName

BREAKING CHANGE: all resourceName attributes have their type changed from string to cdk.PhysicalName.


Pull Request Checklist

  • Testing
    • Unit test added (prefer not to modify an existing test, otherwise, it's probably a breaking change)
    • 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
    • Design: For significant features, design document added to design folder
  • Title and Description
    • Change type: title prefixed with fix, feat and module name in parens, which 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.

@skinny85 skinny85 requested a review from eladb June 15, 2019 01:28
@skinny85 skinny85 requested review from RomainMuller, SoManyHs and a team as code owners June 15, 2019 01:28
@skinny85 skinny85 force-pushed the feature/physical-names-lint branch from e9babf4 to 773da1b Compare June 16, 2019 22:59
@rix0rrr rix0rrr merged commit f0d8127 into aws:master Jun 17, 2019
rix0rrr added a commit that referenced this pull request Jun 17, 2019
@rix0rrr
Copy link
Contributor

rix0rrr commented Jun 17, 2019

Oops, I over-eagerly merged this because I thought it was ready and was trying to get ahead of merge conflicts.

Only later did I realize the PR was still under discussion, so I undid the merge.

However, I can't seem to reopen the PR, so you're going to have to recreate it.

Sorry!

resourceName: this.physicalName.value,
},
});
this.trailArn = resourceIdentifiers.arn;
Copy link
Contributor

Choose a reason for hiding this comment

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

How do we enforce using this and not just trail.trailArn? Seems voluntary... I am worried that most people will not know to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's fine; adding this later is a backwards-compatible change.

const myRepository = new Repository(stack, 'MyRepository', props).notify('myTrigger');
const myRepository = new Repository(stack, 'MyRepository', {
repositoryName: PhysicalName.of('MyRepository'),
}).notify('myTrigger');
Copy link
Contributor

Choose a reason for hiding this comment

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

notify? is this an API we like?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe not, but I don't feel like it's related to the physical name change.

@skinny85 skinny85 deleted the feature/physical-names-lint branch June 17, 2019 15:12
@skinny85
Copy link
Contributor Author

Moved to #2894 after Rico rekt the PR 🙂

@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
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants