-
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(events-targets): support assignPublicIp flag to EcsTask #25660
Conversation
@@ -537,74 +537,6 @@ test('Can use same fargate taskdef multiple times in a rule', () => { | |||
}))).not.toThrow(); | |||
}); | |||
|
|||
test('Isolated subnet does not have AssignPublicIp=true', () => { |
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.
We should not need to remove any tests.
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.
Sorry, I mistakenly removed the test. It's recovered.
@@ -201,14 +211,19 @@ export class EcsTask implements events.IRuleTarget { | |||
const tagList = this.tags; | |||
|
|||
const subnetSelection = this.props.subnetSelection || { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS }; | |||
const assignPublicIp = subnetSelection.subnetType === ec2.SubnetType.PUBLIC ? 'ENABLED' : 'DISABLED'; | |||
|
|||
const assignPublicIp = (this.assignPublicIp ?? subnetSelection.subnetType == ec2.SubnetType.PUBLIC) ? 'ENABLED' : 'DISABLED'; |
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 the case where assignPublicIp
is set to true
, but the subnetSelection is not public? Should we throw an error in that case?
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 public IP addresses can be enabled even in the private subnets. (of course, it's impossible to communicate with the Internet and a meaningless operation.)
I think we shouldn't throw an error in the case since it's the valid setting.
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 think that if the user explicitly sets assignPublicIp=true
then we should throw an error if using private subnets. The user is clearly intending to have a public service or is making a misconfiguration. In either case we should throw an error.
@@ -201,14 +211,19 @@ export class EcsTask implements events.IRuleTarget { | |||
const tagList = this.tags; | |||
|
|||
const subnetSelection = this.props.subnetSelection || { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS }; | |||
const assignPublicIp = subnetSelection.subnetType === ec2.SubnetType.PUBLIC ? 'ENABLED' : 'DISABLED'; | |||
|
|||
const assignPublicIp = (this.assignPublicIp ?? subnetSelection.subnetType == ec2.SubnetType.PUBLIC) ? 'ENABLED' : 'DISABLED'; |
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.
const assignPublicIp = (this.assignPublicIp ?? subnetSelection.subnetType == ec2.SubnetType.PUBLIC) ? 'ENABLED' : 'DISABLED'; | |
const assignPublicIp = (this.assignPublicIp ?? subnetSelection.subnetType === ec2.SubnetType.PUBLIC) ? 'ENABLED' : 'DISABLED'; |
|
||
const assignPublicIp = (this.assignPublicIp ?? subnetSelection.subnetType == ec2.SubnetType.PUBLIC) ? 'ENABLED' : 'DISABLED'; | ||
const launchType = this.taskDefinition.isEc2Compatible ? 'EC2' : 'FARGATE'; | ||
if (assignPublicIp == 'ENABLED' && launchType != 'FARGATE') { |
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.
if (assignPublicIp == 'ENABLED' && launchType != 'FARGATE') { | |
if (assignPublicIp === 'ENABLED' && launchType !== 'FARGATE') { |
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. |
2 similar comments
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. |
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 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 CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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). |
This feature supports
assignPublicIp
toEcsTask
.It specifies whether the task's elastic network interface receives a public IP address.
You can enable it only when
LaunchType
isFARGATE
.In this commit, the choice logic of the
LaunchType
keeps the backwards compatibility.Closes #9233
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license