[AWS ECS] 將建立的 EC2 instance 加入指定的 Cluster

Create Cluster

Launch Container Instance into cluster

#!/bin/bash
echo ECS_CLUSTER=[CLUSTER_NAME] >> /etc/ecs/ecs.config # 不可以寫成 ecs_config 喔!
shell
<powershell>
Import-Module ECSTools
Initialize-ECSAgent -Cluster ‘[CLUSTER_NAME]’ -EnableTaskIAMRole
</powershell>
bash
[ec2-user@ip-172–31–20–243 ~]$ cat /var/log/ecs/ecs-init.log
2017–11–21T09:07:12Z [INFO] Starting Amazon EC2 Container Service Agent
2017–11–21T09:07:14Z [INFO] Agent exited with code 1
2017–11–21T09:07:14Z [INFO] Container name: /ecs-agent
2017–11–21T09:07:14Z [INFO] Removing existing agent container ID: 3c5290616ea532736f2d8d02465b223a0d148eea4741b3453b7381f3ff563f26
2017–11–21T09:07:14Z [INFO] Starting Amazon EC2 Container Service Agent
2017–11–21T09:07:15Z [INFO] Agent exited with code 1
2017–11–21T09:07:15Z [INFO] Container name: /ecs-agent
2017–11–21T09:07:15Z [INFO] Removing existing agent container ID: 2f946d1903237e5380387032faef443e6a649e11f1066e7bceb7257420321949
2017–11–21T09:07:15Z [INFO] Starting Amazon EC2 Container Service Agent
2017–11–21T09:07:15Z [INFO] Agent exited with code 1
2017–11–21T09:07:15Z [INFO] Container name: /ecs-agent
2017–11–21T09:07:15Z [INFO] Removing existing agent container ID: 7d68f5125d14e73b820ce1eeef48f933c564e6ced416512ce7728ee61154ce2c
2017–11–21T09:07:15Z [INFO] Starting Amazon EC2 Container Service Agent
2017–11–21T09:07:16Z [INFO] Agent exited with code 1
2017–11–21T09:07:16Z [INFO] Container name: /ecs-agent
2017–11–21T09:07:16Z [INFO] Removing existing agent container ID: 8f69f81fa411317e28864da8a536b031cc2cc1bfbc6936400eb8e8b44abed603
2017–11–21T09:07:16Z [INFO] Starting Amazon EC2 Container Service Agent
.
.
.
$ [ec2-user@ip-172–31–20–243 ~]$ cat /var/log/ecs/ecs-agent.log.2017–11–21–09
For verbose messaging see aws.Config.CredentialsChainVerboseErrors
2017–11–21T09:11:50Z [INFO] Registering Instance with ECS
2017–11–21T09:11:50Z [ERROR] Could not register: NoCredentialProviders: no valid providers in chain. Deprecated.
For verbose messaging see aws.Config.CredentialsChainVerboseErrors
2017–11–21T09:11:50Z [CRITICAL] Could not create cluster: NoCredentialProviders: no valid providers in chain. Deprecated.
For verbose messaging see aws.Config.CredentialsChainVerboseErrors
2017–11–21T09:11:50Z [ERROR] Error registering: NoCredentialProviders: no valid providers in chain. Deprecated.
For verbose messaging see aws.Config.CredentialsChainVerboseErrors
2017–11–21T09:11:51Z [INFO] Loading configuration
2017–11–21T09:11:51Z [INFO] Loading state! module=”statemanager”
2017–11–21T09:11:51Z [INFO] Event stream ContainerChange start listening…
2017–11–21T09:11:51Z [WARN] Error getting valid credentials (AKID ): NoCredentialProviders: no valid providers in chain. Deprecated.
For verbose messaging see aws.Config.CredentialsChainVerboseErrors
2017–11–21T09:11:51Z [INFO] Registering Instance with ECS
2017–11–21T09:11:51Z [ERROR] Could not register: NoCredentialProviders: no valid providers in chain. Deprecated.
For verbose messaging see aws.Config.CredentialsChainVerboseErrors
2017–11–21T09:11:51Z [CRITICAL] Could not create cluster: NoCredentialProviders: no valid providers in chain. Deprecated.
For verbose messaging see aws.Config.CredentialsChainVerboseErrors
2017–11–21T09:11:51Z [ERROR] Error registering: NoCredentialProviders: no valid providers in chain. Deprecated.
For verbose messaging see aws.Config.CredentialsChainVerboseErrors
.
.
.
{
“Version”: “2012–10–17”,
“Statement”: [
{
“Effect”: “Allow”,
“Action”: [
“ecs:CreateCluster”,
“ecs:DeregisterContainerInstance”,
“ecs:DiscoverPollEndpoint”,
“ecs:Poll”,
“ecs:RegisterContainerInstance”,
“ecs:StartTelemetrySession”,
“ecs:Submit*”,
“ecr:GetAuthorizationToken”,
“ecr:BatchCheckLayerAvailability”,
“ecr:GetDownloadUrlForLayer”,
“ecr:BatchGetImage”,
“logs:CreateLogStream”,
“logs:PutLogEvents”
],
“Resource”: “*”
}
]
}

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store