-
Notifications
You must be signed in to change notification settings - Fork 4k
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(ec2): Prefixlist Constructs #24714
Conversation
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.
Thank you for opening the PR. I am commenting on this as needed to brush up on a few things.
Please note that it is currently recommended to go through the RFC to create new L2 constructs in aws-cdk, and this PR may be closed to go through the recommended flow. For more information, please see the following document
https://github.com/aws/aws-cdk/blob/main/docs/NEW_CONSTRUCTS_GUIDE.md
/** | ||
* The name of the prefix list. | ||
* | ||
* @default None | ||
* | ||
* @remarks | ||
* It is not recommended to use an explicit name. | ||
*/ | ||
readonly prefixListName?: string; |
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.
To avoid the customer having to specify the physical name, generate the physical name in CloudFormation or CDK (if not generated by CloudFormation) if the physical name is not passed.
example that generate in CDK:
constructor(scope: Construct, id: string, props?: PrefixListProps) {
super(scope, id, {
physicalName: props.prefixListName ?? Lazy.string({
produce: () => Names.uniqueResourceName(this, { maxLength: 255, allowedSpecialCharacters: '.-_' }),
}),
});
}
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.
thankyou! fixed.
/** | ||
* The Name of the Prefix List | ||
* | ||
*/ | ||
public readonly name: string; |
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.
prefixListName
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.
fixed.
* The ARN of the Prefix List | ||
* | ||
*/ | ||
public readonly arn: string; |
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.
prefixListArn
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.
fixed.
const prefixList = new CfnPrefixList(this, 'PrefixList', { | ||
addressFamily: props.addressFamily || AddressFamily.IP_V4, | ||
maxEntries: props.maxEntries || props.entries!.length, | ||
prefixListName: this.name, | ||
entries: props.entries || [], | ||
}); | ||
|
||
this.prefixListId = prefixList.attrPrefixListId; | ||
this.arn = prefixList.attrArn; | ||
this.ownerId = prefixList.attrOwnerId; | ||
this.version = prefixList.attrVersion; | ||
this.addressFamily = prefixList.addressFamily; | ||
|
||
this.node.defaultChild = prefixList; |
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.
The ID of the resource that will be the defaultChild should be 'Resource' and do not set the defaultChild directly as in this.node.defaultChild = prefixList;
.
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.
fixed.
}; | ||
}; | ||
|
||
this.name = props?.prefixListName || id; |
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.prefixListName = this.physicalName;
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.
fixed.
if (!props?.maxEntries && !props?.entries) { | ||
throw new Error('Set maxEntries or enrties.'); | ||
} |
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.
What about setting maxEntry to 1 if neither is provided, I expected to be able to create it without setting anything as props is optional, but an error was thrown and I felt sad :(.
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.
fixed.
expect(() => { | ||
new PrefixList(stack, 'prefix-list', { | ||
maxEntries: 100, | ||
prefixListName: 'ThesupercalifragilisticexpialidociouswordisusedtodescribesomethingthatisextraordinarilygoodItwaspopularizedinthemovieMaryPoppinswhichwasreleasedin1964ThewordismadeupofacombinationofLatinandGreekrootsandithassincebecomeapartofpopularcultureWhileitmaybe difficulttospellitisafunwordtosayandcanbeusedtoimpressyourfriendsSothenexttimeyouwanttodescribesomethingasamazingtryusingthewordsupercalifragilisticexpialidocious', |
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.
It is difficult to see that the given prefixListName
is more than 256 characters, so try the following.
new PrefixList(stack, 'prefix-list', {
maxEntries: 100,
prefixListName: 'x'.repeat(256),
});
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.
fixed.
packages/@aws-cdk/aws-ec2/README.md
Outdated
|
||
## Managed prefix lists | ||
|
||
The following demonstrates how to enable [Detailed Monitoring](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-cloudwatch-new.html) for an EC2 instance. Keep in mind that Detailed Monitoring results in [additional charges](http://aws.amazon.com/cloudwatch/pricing/). |
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.
Why is a description of detailed monitoring included?
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.
I'm sorry. This is the "original description". :)
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.
Basically, only capitalise the first letter of the sentence within the comment to ensure consistency in naming.
Examples:
The Id of the Prefix List => The ID of the prefix list
The OwnerId of the Prefix List => The owner ID of the prefix list
Prefix List, prefixlist => prefix list
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.
Thank you. I have fixed it as much as I could.
packages/@aws-cdk/aws-ec2/README.md
Outdated
The following demonstrates how to enable [Detailed Monitoring](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-cloudwatch-new.html) for an EC2 instance. Keep in mind that Detailed Monitoring results in [additional charges](http://aws.amazon.com/cloudwatch/pricing/). | ||
|
||
```ts | ||
new ec2.PrefixList(stack, 'empty-prefix-list', { |
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.
ID should use the Pascal case (at least in this document).
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.
fixed.
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
Thank you for the great comments that helped to resolve the issue. I have made some minor corrections. I will address the remaining comments later. |
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
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.
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.
The pull request linter fails with the following errors:
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 |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
I accidentally broke the branch while trying to resolve conflicts #24714 . I have addressed all of the comments made by @WinterYukky who reviewed my code. --- I created this Construct so that I can use AWS::EC2::PrefixList quickly. The differences from L1 are as follows: - If AddressFamily is not specified, ipv4 is used by default. - If maxEntries is not specified, the number of entries is automatically calculated from the entries array and set as maxEntries. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
I created this Construct so that I can use AWS::EC2::PrefixList quickly.
The differences from L1 are as follows:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license