Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit c308a67

Browse files
committed
ECS: supporting x-aws-assign_public_ip
Allowing users to choose whether their instances should get a public IP address or not. Defaulting to "no". Signed-off-by: Nitzan Raz <[email protected]>
1 parent bd636e0 commit c308a67

File tree

5 files changed

+8
-3
lines changed

5 files changed

+8
-3
lines changed

ecs/cloudformation.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,10 @@ func (b *ecsAPIService) createService(project *types.Project, service types.Serv
235235
return err
236236
}
237237

238-
assignPublicIP := ecsapi.AssignPublicIpEnabled
238+
assignPublicIP := "DISABLED"
239+
if assignPublicIPSetting, ok := service.Extensions[extensionAssignPublicIP]; ok && assignPublicIPSetting.(bool) {
240+
assignPublicIP = ecsapi.AssignPublicIpEnabled
241+
}
239242
launchType := ecsapi.LaunchTypeFargate
240243
platformVersion := "1.4.0" // LATEST which is set to 1.3.0 (?) which doesn’t allow efs volumes.
241244
if requireEC2(service) {

ecs/testdata/input/slightly-complex-service.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ services:
33
image: nginx
44
ports:
55
- "80:80"
6+
x-aws-assign_public_ip: true
67

78
sensitive:
89
image: httpd

ecs/testdata/simple-cloudformation-conversion.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Resources:
8181
Ref: SimpleTCP80TargetGroup
8282
NetworkConfiguration:
8383
AwsvpcConfiguration:
84-
AssignPublicIp: ENABLED
84+
AssignPublicIp: DISABLED
8585
SecurityGroups:
8686
- Ref: DefaultNetwork
8787
Subnets:

ecs/testdata/slightly-complex-cloudformation-conversion.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ Resources:
220220
LaunchType: FARGATE
221221
NetworkConfiguration:
222222
AwsvpcConfiguration:
223-
AssignPublicIp: ENABLED
223+
AssignPublicIp: DISABLED
224224
SecurityGroups:
225225
- Ref: DefaultNetwork
226226
Subnets:

ecs/x.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ const (
3131
extensionManagedPolicies = "x-aws-policies"
3232
extensionAutoScaling = "x-aws-autoscaling"
3333
extensionCloudFormation = "x-aws-cloudformation"
34+
extensionAssignPublicIP = "x-aws-assign_public_ip"
3435
)

0 commit comments

Comments
 (0)