-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
provider/aws: Add support for ECS svc - LB target group
- Loading branch information
1 parent
0007346
commit f08d2e6
Showing
11 changed files
with
653 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# ECS with ALB example | ||
|
||
This example shows how to launch an ECS service fronted with Application Load Balancer. | ||
|
||
The example uses latest CoreOS Stable AMIs. | ||
|
||
To run, configure your AWS provider as described in https://www.terraform.io/docs/providers/aws/index.html | ||
|
||
## Get up and running | ||
|
||
Planning phase | ||
|
||
``` | ||
terraform plan \ | ||
-var admin_cidr_ingress='"{your_ip_address}/32"' \ | ||
-var key_name={your_key_name} | ||
``` | ||
|
||
Apply phase | ||
|
||
``` | ||
terraform apply \ | ||
-var admin_cidr_ingress='"{your_ip_address}/32"' \ | ||
-var key_name={your_key_name} | ||
``` | ||
|
||
Once the stack is created, wait for few minutes and test the stack by launching a browser with ELB url. | ||
|
||
## Destroy :boom: | ||
|
||
``` | ||
terraform destroy | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#cloud-config | ||
coreos: | ||
units: | ||
- name: update-engine.service | ||
command: stop | ||
- name: amazon-ecs-agent.service | ||
command: start | ||
runtime: true | ||
content: | | ||
[Unit] | ||
Description=AWS ECS Agent | ||
Documentation=https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ | ||
Requires=docker.socket | ||
After=docker.socket | ||
[Service] | ||
Environment=ECS_CLUSTER=${ecs_cluster_name} | ||
Environment=ECS_LOGLEVEL=${ecs_log_level} | ||
Environment=ECS_VERSION=${ecs_agent_version} | ||
Restart=on-failure | ||
RestartSec=30 | ||
RestartPreventExitStatus=5 | ||
SyslogIdentifier=ecs-agent | ||
ExecStartPre=-/bin/mkdir -p /var/log/ecs /var/ecs-data /etc/ecs | ||
ExecStartPre=-/usr/bin/docker kill ecs-agent | ||
ExecStartPre=-/usr/bin/docker rm ecs-agent | ||
ExecStartPre=/usr/bin/docker pull amazon/amazon-ecs-agent:$${ECS_VERSION} | ||
ExecStart=/usr/bin/docker run --name ecs-agent \ | ||
--volume=/var/run/docker.sock:/var/run/docker.sock \ | ||
--volume=/var/log/ecs:/log \ | ||
--volume=/var/ecs-data:/data \ | ||
--volume=/sys/fs/cgroup:/sys/fs/cgroup:ro \ | ||
--volume=/run/docker/execdriver/native:/var/lib/docker/execdriver/native:ro \ | ||
--publish=127.0.0.1:51678:51678 \ | ||
--env=ECS_LOGFILE=/log/ecs-agent.log \ | ||
--env=ECS_LOGLEVEL=$${ECS_LOGLEVEL} \ | ||
--env=ECS_DATADIR=/data \ | ||
--env=ECS_CLUSTER=$${ECS_CLUSTER} \ | ||
--env=ECS_AVAILABLE_LOGGING_DRIVERS='["awslogs"]' \ | ||
--log-driver=awslogs \ | ||
--log-opt awslogs-region=${aws_region} \ | ||
--log-opt awslogs-group=${ecs_log_group_name} \ | ||
amazon/amazon-ecs-agent:$${ECS_VERSION} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Sid": "ecsInstanceRole", | ||
"Effect": "Allow", | ||
"Action": [ | ||
"ecs:DeregisterContainerInstance", | ||
"ecs:DiscoverPollEndpoint", | ||
"ecs:Poll", | ||
"ecs:RegisterContainerInstance", | ||
"ecs:Submit*" | ||
], | ||
"Resource": [ | ||
"*" | ||
] | ||
}, | ||
{ | ||
"Sid": "allowLoggingToCloudWatch", | ||
"Effect": "Allow", | ||
"Action": [ | ||
"logs:CreateLogStream", | ||
"logs:PutLogEvents" | ||
], | ||
"Resource": [ | ||
"${app_log_group_arn}", | ||
"${ecs_log_group_arn}" | ||
] | ||
} | ||
] | ||
} |
Oops, something went wrong.