diff --git a/internal/pkg/object/command/ecs/ecs.go b/internal/pkg/object/command/ecs/ecs.go index b2750b7..8ecbe3e 100644 --- a/internal/pkg/object/command/ecs/ecs.go +++ b/internal/pkg/object/command/ecs/ecs.go @@ -57,6 +57,7 @@ type clusterContext struct { type vpcConfig struct { Subnets []string `yaml:"subnets,omitempty" json:"subnets,omitempty"` SecurityGroups []string `yaml:"security_groups,omitempty" json:"security_groups,omitempty"` + AssignPublicIp bool `yaml:"assign_public_ip,omitempty" json:"assign_public_ip,omitempty"` } // Task definition wrapper with pre-computed essential containers map @@ -649,7 +650,7 @@ func runTask(ctx context.Context, execCtx *executionContext, startedBy string, t AwsvpcConfiguration: &types.AwsVpcConfiguration{ Subnets: execCtx.ClusterConfig.VPCConfig.Subnets, SecurityGroups: execCtx.ClusterConfig.VPCConfig.SecurityGroups, - AssignPublicIp: types.AssignPublicIpDisabled, + AssignPublicIp: assignPublicIp(execCtx.ClusterConfig.VPCConfig.AssignPublicIp), }, }, } @@ -841,6 +842,14 @@ func retryWithBackoff(ctx context.Context, maxRetries int, op func() error) erro return err } +// assignPublicIp converts a bool to the ECS AssignPublicIp enum value. +func assignPublicIp(enabled bool) types.AssignPublicIp { + if enabled { + return types.AssignPublicIpEnabled + } + return types.AssignPublicIpDisabled +} + // isThrottlingError reports whether err is an AWS throttling error. func isThrottlingError(err error) bool { var apiErr smithy.APIError