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(ses): add configurationSetArn property on configurationSet resource #29903

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fredericbarthelet
Copy link
Contributor

@fredericbarthelet fredericbarthelet commented Apr 19, 2024

Issue

Closes #29902

Reason for this change

Adds configurationSetArn property on ConfigurationSet construct to ease up building Policy referencing such construct

Description of changes

Similar implementation to recently added emailIdentityArn property on EmailIdentity construct. The implementation leverages the use of stack.formatArn to build AWS::SES::ConfigurationSet arn

Description of how you validated changes

Did not add any test as this would basically mean testing formatArn function itself.

Checklist


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

@github-actions github-actions bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label Apr 19, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team April 19, 2024 09:27
@github-actions github-actions bot added feature-request A feature should be added or improved. p2 labels Apr 19, 2024
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 has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@fredericbarthelet
Copy link
Contributor Author

Exemption Request

  • Change to a README file: only the auto-generated doc for ConfigurationSet construct is affected by this PR
  • Change to a test file: testing this would feel like testing formatArn method

Copy link
Contributor

@nmussy nmussy left a comment

Choose a reason for hiding this comment

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

While I agree with your exemption request about the README and integ file changes, I think we need to cover the new property with a unit test

Comment on lines 172 to 176
this.configurationSetArn = this.stack.formatArn({
service: 'ses',
resource: 'configuration-set',
resourceName: this.configurationSetName,
});
Copy link
Contributor

@nmussy nmussy Apr 19, 2024

Choose a reason for hiding this comment

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

I think a getter method would be cleaner here, and would avoid having to duplicate this code in the Import class:

public get configurationSetArn(): string {
  return this.stack.formatArn({
    service: 'ses',
    resource: 'configuration-set',
    resourceName: this.configurationSetName,
  });
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nmussy thanks for your comment. Not sure about your proposal, do you want me to implement a base class ConfigurationSetBase that both Import and ConfigurationSet will extend in order for them to both have this method? Found references to this pattern in https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md#abstract-base
I'll implement something based on that. Let me know if you had something else in mind :)

I was originally inspired by EmailIdentity construct from aws-ses which has this duplicated code.

public readonly emailIdentityArn = this.stack.formatArn({
service: 'ses',
resource: 'identity',
resourceName: this.emailIdentityName,
});

this.emailIdentityArn = this.stack.formatArn({
service: 'ses',
resource: 'identity',
resourceName: this.emailIdentityName,
});

@fredericbarthelet
Copy link
Contributor Author

@nmussy thanks for your review.

I deduplicated the code and added unit tests.
Let me know if I should add any additional changes.

Thanks :) !

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

Copy link
Contributor

@nmussy nmussy left a comment

Choose a reason for hiding this comment

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

LGTM, just unsure about the @attribute tag 👍

Comment on lines +22 to +24
* @attribute
*/
readonly configurationSetArn: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

The @attribute might not be appropriate since it's derived from the resource ref, a maintainer should weigh in on 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.

In case it helps, the exemple construct from the coding guideline uses @attribute for the ARN property even if it is computed manually (like in this case) :

  • exempleResourceArn is tagged with @attribute

/**
* The ARN of example resource.
* Equivalent to doing `{ 'Fn::GetAtt': ['LogicalId', 'Arn' ]}`
* in CloudFormation if the underlying CloudFormation resource
* surfaces the ARN as a return value -
* if not, we usually construct the ARN "by hand" in the construct,
* using the Fn::Join function.
*
* It needs to be annotated with '@attribute' if the underlying CloudFormation resource
* surfaces the ARN as a return value.
*
* @attribute
*/
readonly exampleResourceArn: string;

  • exempleResourceArn is constructed manually in from static methods and constructor
    public readonly exampleResourceName = exampleResourceName;
    // Since we have the name, we have to generate the ARN,
    // using the Stack.formatArn helper method from the core library.
    // We have to know the ARN components of ExampleResource in a few places, so,
    // to avoid duplication, extract that into a module-private function
    public readonly exampleResourceArn = core.Stack.of(scope)
    .formatArn(exampleResourceArnComponents(exampleResourceName));

The only doubt I have is regarding this precision : It needs to be annotated with '@attribute' if the underlying CloudFormation resource surfaces the ARN as a return value.
CloudFormation does not surface AWS::SES::ConfigurationSet ARN.

@aws-cdk-automation
Copy link
Collaborator

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.

If you would like to request an exemption from the status checks or clarification on feedback, please leave a comment on this PR containing Exemption Request and/or Clarification Request.

✅ A exemption request has been requested. Please wait for a maintainer's review.

@fredericbarthelet
Copy link
Contributor Author

Any chance a maintainer can review and weigh in on the decision to keep or remove the @attribute annotation on configurationSetArn :)? @nmussy should I ping anybody in particular on this PR? Thanks

@nmussy
Copy link
Contributor

nmussy commented May 7, 2024

They'll address it when they review the PR 👍

@aws-cdk-automation
Copy link
Collaborator

This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(ses): add configurationSetArn property on ConfigurationSet
3 participants