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(ec2): ipv6AddressCount property for an instance #31076

Merged
merged 10 commits into from
Aug 28, 2024

Conversation

badmintoncryer
Copy link
Contributor

Issue # (if applicable)

Closes #31075.

Reason for this change

AWS CDK cannot configure ipv6AddressCount property but cloudformation can do that.

Description of changes

  • Add ipv6AddressCount to InstanceProps
  • Check whether ipv6AddressCount is a positive integer

Description of how you validated changes

Add both unit and integ tests

Checklist


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

@aws-cdk-automation aws-cdk-automation requested a review from a team August 11, 2024 00:39
@github-actions github-actions bot added feature-request A feature should be added or improved. p2 distinguished-contributor [Pilot] contributed 50+ PRs to the CDK labels Aug 11, 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.

@aws-cdk-automation aws-cdk-automation dismissed their stale review August 11, 2024 01:05

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

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Aug 11, 2024
Copy link
Contributor

@go-to-k go-to-k left a comment

Choose a reason for hiding this comment

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

It seems that the ipv6AddressCount and network interfaces should not be specified together.

You cannot specify this option and the network interfaces option in the same request.

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-instance.html#cfn-ec2-instance-ipv6addresscount

Also, when the associatePublicIpAddress is specified (can be true or false), network interfaces array is automatically set.

https://github.com/aws/aws-cdk/blob/v2.151.0/packages/aws-cdk-lib/aws-ec2/lib/instance.ts#L499-L507

In other words, specifying the ipv6AddressCount and the associatePublicIpAddress should result in an error for CFn. Therefore, how about putting in a validation for this? (It would also be good to add that description to the JSDoc.)

P.S.) I actually tried to run the integ test with those properties specified and CFn got an error.

Resource handler returned message: "Network interfaces and an instance-level IPv6 address count may not be specified on the same request (Service: Ec2, Status Code: 400, Request ID: ...

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Aug 13, 2024
}
}

const testCase = new TestStack(app, 'TestStack');
Copy link
Contributor

Choose a reason for hiding this comment

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

How about making the stack name specific to this integ test? Because there are often other integ tests with stacks of the same name, which will fail if we try to run them in parallel.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated it!

@badmintoncryer
Copy link
Contributor Author

badmintoncryer commented Aug 15, 2024

@go-to-k Thank you for your review and great suggestion!! I've addressed your comments.

Copy link
Contributor

@go-to-k go-to-k left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM.

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Aug 16, 2024
@badmintoncryer
Copy link
Contributor Author

Thanks always!

Comment on lines +530 to +537
if (
props.ipv6AddressCount !== undefined &&
!Token.isUnresolved(props.ipv6AddressCount) &&
(props.ipv6AddressCount < 0 || !Number.isInteger(props.ipv6AddressCount))
) {
throw new Error(`\'ipv6AddressCount\' must be a non-negative integer, got: ${props.ipv6AddressCount}`);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Curious that if there's a upper bound value for this property?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to create an instance by specifying ipv6AddressCount as 2000.

Result:

Failed resources:
InstanceIpv6AddressCountTestStack | 8:04:58 AM | CREATE_FAILED        | AWS::EC2::Instance                    | Instance (InstanceC1063A87) Resource handler returned message: "Address count 2000 per interface exceeds the limit for m5.large (Service: Ec2, Status Code: 400, Request ID: 6fcb0c3e-a029-4b62-9e31-4452642bede8)" (RequestToken: 498ff895-1532-848d-2a6b-2e2af377efb0, HandlerErrorCode: InvalidRequest)

It seems that the upper limit varies depending on the instance type. However, I couldn't find any documentation on this...

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for giving it a try. To be clear I don't want us to do the validation, but just curious about this.

Copy link
Contributor

@GavinZZ GavinZZ left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

mergify bot commented Aug 28, 2024

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 aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Aug 28, 2024
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 15f9f5b
  • 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 e3e5e1c into aws:main Aug 28, 2024
12 checks passed
Copy link
Contributor

mergify bot commented Aug 28, 2024

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).

Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 28, 2024
@badmintoncryer badmintoncryer deleted the ipv6AddressCount branch August 28, 2024 00:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
distinguished-contributor [Pilot] contributed 50+ 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.

ec2: support for specify IPv6 address count for an instance
4 participants