Skip to content

Commit

Permalink
Merge pull request #38 from annuh/master
Browse files Browse the repository at this point in the history
Add support for AssignPublicIp
  • Loading branch information
josmo authored Jun 26, 2019
2 parents 26f47e6 + 90da3db commit 6951d77
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ Use this plugin for deploying a docker container application to AWS EC2 Containe
* `task_memory` - The amount of memory (in MiB) used by the task.It can be expressed as an integer using MiB, for example 1024, or as a string using GB. Required if using Fargate launch type
* `task_execution_role_arn` - The Amazon Resource Name (ARN) of the task execution role that the Amazon ECS container agent and the Docker daemon can assume.
* `compatibilities` - List of launch types supported by the task, defaults to EC2 if not specified

* `service_network_assign_public_ip` - Whether the task's elastic network interface receives a public IP address. The default value is DISABLED.
* `service_network_subnets` - The security groups associated with the task or service. If you do not specify a security group, the default security group for the VPC is used. There is a limit of 5 security groups that can be specified per AwsVpcConfiguration.
* `service_network_security_groups` - The subnets associated with the task or service. There is a limit of 16 subnets that can be specified per AwsVpcConfiguration.

## Example

Expand Down
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ func main() {
Value: 5,
EnvVar: "PLUGIN_HEALTHCHECK_TIMEOUT",
},
cli.StringFlag{
Name: "service-network-assign-public-ip",
Usage: "Assign public IP (ENABLED|DISABLED), defaults to DISABLED",
Value: "DISABLED",
EnvVar: "PLUGIN_SERVICE_NETWORK_ASSIGN_PUBLIC_IP",
},
cli.StringSliceFlag{
Name: "service-network-security-groups",
Usage: "The security groups to associate with the service",
Expand Down Expand Up @@ -235,6 +241,7 @@ func run(c *cli.Context) error {
HealthCheckRetries: c.Int64("healthcheck-retries"),
HealthCheckStartPeriod: c.Int64("healthcheck-start-period"),
HealthCheckTimeout: c.Int64("healthcheck-timeout"),
ServiceNetworkAssignPublicIp: c.String("service-network-assign-public-ip"),
ServiceNetworkSecurityGroups: c.StringSlice("service-network-security-groups"),
ServiceNetworkSubnets: c.StringSlice("service-network-subnets"),
}
Expand Down
7 changes: 7 additions & 0 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ type Plugin struct {
HealthCheckStartPeriod int64
HealthCheckTimeout int64

// ServiceNetworkAssignPublicIP - Whether the task's elastic network interface receives a public IP address. The default value is DISABLED.
ServiceNetworkAssignPublicIp string

// ServiceNetworkSecurityGroups represents the VPC security groups to use
// when running awsvpc network mode.
ServiceNetworkSecurityGroups []string
Expand Down Expand Up @@ -293,6 +296,10 @@ func (p *Plugin) setupServiceNetworkConfiguration() *ecs.NetworkConfiguration {
if p.NetworkMode != ecs.NetworkModeAwsvpc {
return &netConfig
}

if len(p.ServiceNetworkAssignPublicIp) != 0 {
netConfig.AwsvpcConfiguration.SetAssignPublicIp(p.ServiceNetworkAssignPublicIp);
}

if len(p.ServiceNetworkSubnets) > 0 {
netConfig.AwsvpcConfiguration.SetSubnets(aws.StringSlice(p.ServiceNetworkSubnets))
Expand Down

0 comments on commit 6951d77

Please sign in to comment.