Reputation: 2015
I've just created an ECS cluster via the AWS console. During that process, I specified the VPC I wanted it to use, as well as four subnets.
Now I can't find any indication--neither in the console, nor via the CLI--that this actually happened. I see that the cluster exists, but I cannot get any details regarding its network disposition.
I've tried using the aws
client, with all of the arguments to --include
that are accepted (SETTINGS
, ATTACHMENTS
, CONFIGURATION
, et cetera), but aws ecs describe-clusters --cluster foocluster --include SETTINGS
(for example) shows me nothing but the bare details.
Upvotes: 5
Views: 3936
Reputation: 238897
Cluster is not specific to any VPC, thus there is no association between an ECS cluster and a VPC. VPC are specific to ECS tasks and services.
AWS console just helped you to create a VPC as a separate entity to cluster. This way you can launch your tasks and services to that VPC. But you can launch them to any other VPC as well.
Upvotes: 3
Reputation: 28738
I don't understand why we're prompted to specify a VPC and Subnets when creating an ECS cluster via console... but that's how it is.
The ECS console follows what I find is an increasingly common pattern of triggering a CloudFormation job, rather than directly provisioning resources. The end result is identical (your resource is deployed) but having a catalog of all provisioned resources can be useful. In this case your specified parameters (VPC, Subnet, etc) are all stored in the corresponding CloudFormation stack, and can be retrieved from there.
The process is pretty simple:
Parameter
valuesYou can do all this in a one-liner via the CLI.
CLUSTER_NAME=my-cluster
aws cloudformation describe-stacks --query \
"Stacks[?contains(StackName, 'Infra-ECS-Cluster-$CLUSTER_NAME')] | [0].Parameters"
Note that this assumes the ECS "Create Cluster" page continues to name Stacks according to this pattern (i.e. Infra-ECS-Cluster-{cluster_name}-{random_string}
).
I find the "query" parameter easy to read but hard to write; you can find tutorials and guides on writing these JMESPath queries. In this case the query is filtering where StackName
contains the specified value, piping the results to a second operator, taking the first result1 and selecting its Parameters
property.
1There can be multiple matches if the Stack was created/deleted/recreated etc. You could improve the query to only find CREATE COMPLETE
or UPDATE COMPLETE
Stacks if necessary.
Upvotes: 3