Skip to content

feat(aws-certificatemanager): Add ability to specify the certificate name #22301

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

Merged
merged 13 commits into from
Oct 7, 2022

Conversation

jmortlock
Copy link
Contributor

@jmortlock jmortlock commented Sep 30, 2022


Like other AWS resources (VPC, TargetGroups,etc) they do not have an actual physical name but can be assigned an AWS designated tag which will be displayed in the web console. This is useful when you have many certificates to determine what is what.

I largely followed the pattern set about in other CDK constructs, for example in vpc.ts I also followed the convention set elsewhere name tag is used by defaulting the value too this.node.path

I believe this is also an important first step towards any implementation of #10792

I tried added integration tests, however due to the requirement of needing to validate the certificate I don't think this is possible. Currently there are no other integration tests for this module.

I have attached a screenshot of the failed integ-test (validation required) which shows the name tag in action

CustomCertificate

All Submissions:

Adding new Unconventional Dependencies:

  • This PR adds new unconventional dependencies following the process described here

New Features

  • Have you added the new feature to an integration test?
    • Did you use yarn integ to deploy the infrastructure and generate the snapshot (i.e. yarn integ without --dry-run)?

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

Sorry, something went wrong.

@github-actions github-actions bot added repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK p2 labels Sep 30, 2022
@gitpod-io
Copy link

gitpod-io bot commented Sep 30, 2022

@aws-cdk-automation aws-cdk-automation requested a review from a team September 30, 2022 06:50
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The Pull Request Linter fails with the following errors:

❌ Features must contain a change to a README file.
❌ Features must contain a change to an integration test file and the resulting snapshot.

PRs must pass status checks before we can provide a meaningful review.

@mergify mergify bot dismissed aws-cdk-automation’s stale review September 30, 2022 07:22

Pull request has been modified.

Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The Pull Request Linter fails with the following errors:

❌ Features must contain a change to an integration test file and the resulting snapshot.

PRs must pass status checks before we can provide a meaningful review.

@jmortlock
Copy link
Contributor Author

The build is failing due to test failure in ecs-patterns. However the integ test cannot be regenerate due to certificate validation issue. I'm not sure how the original snapshot was generated.

aws-ecs-integ-alb-fg-idletimeout | 6:02:19 pm | CREATE_FAILED        | AWS::CertificateManager::Certificate      | myService/Certificate (myServiceCertificate152F9DDA) DNS Record Set is not available. Certificate is in FAILED status.

A workaround would be to remove the default certificateName but I feel consistency with other constructs its important.

@mergify mergify bot dismissed aws-cdk-automation’s stale review September 30, 2022 22:57

Pull request has been modified.

Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The Pull Request Linter fails with the following errors:

❌ Features must contain a change to an integration test file and the resulting snapshot.

PRs must pass status checks before we can provide a meaningful review.

@jmortlock
Copy link
Contributor Author

For now I have manually updated the snapshot

@aws-cdk-automation aws-cdk-automation dismissed their stale review September 30, 2022 23:00

Pull Request updated. Dissmissing previous PRLinter Review.

Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The Pull Request Linter fails with the following errors:

❌ Features must contain a change to an integration test file and the resulting snapshot.

PRs must pass status checks before we can provide a meaningful review.

@aws-cdk-automation aws-cdk-automation dismissed their stale review September 30, 2022 23:05

Pull Request updated. Dissmissing previous PRLinter Review.

Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The Pull Request Linter fails with the following errors:

❌ Features must contain a change to an integration test file and the resulting snapshot.

PRs must pass status checks before we can provide a meaningful review.

Copy link
Contributor

@corymhall corymhall left a comment

Choose a reason for hiding this comment

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

Just a couple of nits

@corymhall
Copy link
Contributor

I tried added integration tests, however due to the requirement of needing to validate the certificate I don't think this is possible. Currently there are no other integration tests for this module.

I just added an integration test for DnsValidatedCertificate. If you do have the ability to request a valid certificate then you can follow this model. Essentially You set some env vars that the runner will use when performing the deploy and then it will use some generic built in values when it saves the snapshot.

const hostedZoneId = process.env.CDK_INTEG_HOSTED_ZONE_ID ?? process.env.HOSTED_ZONE_ID;
if (!hostedZoneId) throw new Error('For this test you must provide your own HostedZoneId as an env var "HOSTED_ZONE_ID"');
const hostedZoneName = process.env.CDK_INTEG_HOSTED_ZONE_NAME ?? process.env.HOSTED_ZONE_NAME;
if (!hostedZoneName) throw new Error('For this test you must provide your own HostedZoneName as an env var "HOSTED_ZONE_NAME"');
const domainName = process.env.CDK_INTEG_DOMAIN_NAME ?? process.env.DOMAIN_NAME;
if (!domainName) throw new Error('For this test you must provide your own Domain Name as an env var "DOMAIN_NAME"');

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@mergify mergify bot dismissed stale reviews from corymhall and aws-cdk-automation October 4, 2022 05:49

Pull request has been modified.

Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The Pull Request Linter fails with the following errors:

❌ Features must contain a change to an integration test file and the resulting snapshot.

PRs must pass status checks before we can provide a meaningful review.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@aws-cdk-automation aws-cdk-automation dismissed their stale review October 6, 2022 02:52

✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.

Copy link
Contributor

@corymhall corymhall left a comment

Choose a reason for hiding this comment

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

Thanks for adding the integ test! Just 1 last minor comment and then I think we are good.

@@ -247,6 +261,8 @@ export class Certificate extends CertificateBase implements ICertificate {
certificateTransparencyLoggingPreference,
});

Tags.of(cert).add(NAME_TAG, props.certificateName || this.node.path);
Copy link
Contributor

Choose a reason for hiding this comment

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

The Tag value has a limit of 255 characters. Can you add something here to restrict the value to that? I don't think it is as much of a problem if the user provides a certificateName, but node.path might hit that limit.

Maybe just a value.slice(0, 255);

https://docs.aws.amazon.com/acm/latest/userguide/tags-restrictions.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch; I have sliced the auto-generated certificate name but left the user inputted value alone.

@mergify mergify bot dismissed corymhall’s stale review October 6, 2022 22:25

Pull request has been modified.

@mergify
Copy link
Contributor

mergify bot commented Oct 7, 2022

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify
Copy link
Contributor

mergify bot commented Oct 7, 2022

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: c0836ee
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 614ba92 into aws:main Oct 7, 2022
@mergify
Copy link
Contributor

mergify bot commented Oct 7, 2022

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

arewa pushed a commit to arewa/aws-cdk that referenced this pull request Oct 8, 2022
…name (aws#22301)

----
Like other AWS resources (VPC, TargetGroups,etc) they do not have an actual physical name but can be assigned an AWS designated tag which will be displayed in the web console. This is useful when you have many certificates to determine what is what.

I largely followed the pattern set about in other CDK constructs, for example in `vpc.ts` I also followed the convention set elsewhere name tag is used by defaulting the value too `this.node.path`

I believe this is also an important first step towards any implementation of aws#10792

I tried added integration tests, however due to the requirement of needing to validate the certificate I don't think this is possible. Currently there are no other integration tests for this module.

I have attached a screenshot of the failed integ-test (validation required) which shows the name tag in action

![CustomCertificate](https://user-images.githubusercontent.com/10041761/193207874-871d55e6-9a8e-4e8a-aa77-ae718e4bc1d4.png)



### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
homakk pushed a commit to homakk/aws-cdk that referenced this pull request Dec 1, 2022
…name (aws#22301)

----
Like other AWS resources (VPC, TargetGroups,etc) they do not have an actual physical name but can be assigned an AWS designated tag which will be displayed in the web console. This is useful when you have many certificates to determine what is what.

I largely followed the pattern set about in other CDK constructs, for example in `vpc.ts` I also followed the convention set elsewhere name tag is used by defaulting the value too `this.node.path`

I believe this is also an important first step towards any implementation of aws#10792

I tried added integration tests, however due to the requirement of needing to validate the certificate I don't think this is possible. Currently there are no other integration tests for this module.

I have attached a screenshot of the failed integ-test (validation required) which shows the name tag in action

![CustomCertificate](https://user-images.githubusercontent.com/10041761/193207874-871d55e6-9a8e-4e8a-aa77-ae718e4bc1d4.png)



### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2 repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants