Skip to content
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

ECS module #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

ECS module #54

wants to merge 1 commit into from

Conversation

neilmcgibbon
Copy link

First attempt at adding a module to support AWS ECS discovery.

For containers running on AWS ECS, the exposed port of the service may be dynamically assigned .

This provider - when initialised with the correct cluster, service and container names - will attempt to locate the container running the service and provide the container host IP address and dynamically assigned port.

For example if we have a cluster consul-cluster running two instances of service consul-server-svc, which in turn each run a single consul server container names consul-server, exposing the default 8500 http port] we might have this setup:

cluster instance IP service container port dynamic port
consul-cluster 10.0.0.1 consul-server-svc consul-server 8500 32445
consul-cluster 10.0.0.2 consul-server-svc consul-server 8500 31922

This service would return the following two address strings, to access the service from outside the container instance host: ["10.0.0.1:32445", "10.0.0.2:31922"]

This provider (awsecs) takes the following parameters:

argument notes
region The AWS region. Default to region of instance
addr_type "private_v4", "public_v4" or "public_v6". Defaults to "private_v4". (Taken directly from aws provider)
service_port The port that the container exposes for the service. E.g. for Consul it would likely be 8500
cluster_name The name of the cluster where the service is deployed
service_name The name of the service
container_name The name of the running container within the service
access_key_id The AWS access key to use. (Taken directly from aws provider)
secret_access_key The AWS secret access key to use.(Taken directly from aws provider)

Test format copied from the provider/aws/aws_discover_test.go file.
Terraform template(s) created and tested in eu-west-2.

Follows format provided in main README.md:

$ cd test/tf/awsecs
$ export AWS_ACCESS_KEY_ID=... AWS_ACCESS_KEY_SECRET=... AWS_REGION=...
$ terraform init
...
$ terraform apply
...
cd ../../../
go test -v ./provider/awsecs

Formatting
@dekimsey
Copy link

In ECS one can use the awsvpc networking mode which doesn't dynamically generate ports. If ECS's deployment mode is EC2 instances, cloud auto-join works fine with (--host=net). The current discovery mechanisms cannot see servers running in ECS w/ awsvpc. Having support would be amazing (it'd also let servers run in fargate).

@hashicorp-cla
Copy link

hashicorp-cla commented Jun 8, 2020

CLA assistant check
All committers have signed the CLA.

@fdr2 fdr2 mentioned this pull request Jul 3, 2022
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants