How to join ec2 to ecs cluster in diffirent region

0

Hello!!

I want to register ec2 p3.16xlarge in us-east-1 with ecs optimize gpu ami to ecs cluster in ap-northeast-1 my ec2 instance has'nt IAM instance role here is my ec2 user data

#!/bin/bash echo ECS_CLUSTER=<MY_ECS_CLUSTER_NAME> >> /etc/ecs/ecs.config; echo ECS_ENABLE_GPU_SUPPORT=true >> /etc/ecs/ecs.config

curl --proto "https" -o "/tmp/ecs-anywhere-install.sh" "https://amazon-ecs-agent.s3.amazonaws.com/ecs-anywhere-install-latest.sh" && bash /tmp/ecs-anywhere-install.sh --region "ap-northeast-1" --cluster "<MY_ECS_CLUSTER_NAME>" --activation-id "<activation-id>" --activation-code "<activation-code>"

with normal ami i can join with EXTERNAL container instance but with gpu optimize ami i have error

level=info time=2024-04-01T05:25:36Z msg="Loading state!" module=state_manager.go level=info time=2024-04-01T05:25:36Z msg="eni watcher has been initialized" module=watcher_linux.go level=error time=2024-04-01T05:25:36Z msg="Error getting valid credentials: NoCredentialProviders: no valid providers in chain. Deprecated.\n\tFor verbose messaging see aws.Config.CredentialsChainVerboseErrors" module=agent.go level=info time=2024-04-01T05:25:37Z msg="Successfully loaded Appnet agent container tarball: /managed-agents/serviceconnect/ecs-service-connect-agent.interface-v1.tar" image="ecs-service-connect-agent:interface-v1" level=info time=2024-04-01T05:25:37Z msg="Registering Instance with ECS" level=info time=2024-04-01T05:25:37Z msg="Remaining memory" remainingMemory=3871 level=error time=2024-04-01T05:25:37Z msg="Unable to register as a container instance with ECS" error="NoCredentialProviders: no valid providers in chain. Deprecated.\n\tFor verbose messaging see aws.Config.CredentialsChainVerboseErrors" level=error time=2024-04-01T05:25:37Z msg="Error registering container instance" error="NoCredentialProviders: no valid providers in chain. Deprecated.\n\tFor verbose messaging see aws.Config.CredentialsChainVerboseErrors" level=error time=2024-04-01T05:25:52Z msg="Driver log level mapping not found" module=log.go level=error time=2024-04-01T05:25:52Z msg="Instance log level mapping not found" module=log.go level=error time=2024-04-01T05:25:52Z msg="Error getting ECS instance credentials from default chain: NoCredentialProviders: no valid providers in chain. Deprecated.\n\tFor verbose messaging see aws.Config.CredentialsChainVerboseErrors" level=info time=2024-04-01T05:25:52Z msg="Starting Amazon ECS Agent" version="1.82.1" commit="3d608ab0" level=info time=2024-04-01T05:25:52Z msg="Loading configuration" level=error time=2024-04-01T05:25:52Z msg="Error getting ECS instance credentials from default chain: NoCredentialProviders: no valid providers in chain. Deprecated.\n\tFor verbose messaging see aws.Config.CredentialsChainVerboseErrors" level=info time=2024-04-01T05:25:52Z msg="Unable to get Docker client for version 1.42: Error response from daemon: client version 1.42 is too new. Maximum supported API version is 1.41" module=sdkclientfactory.go level=info time=2024-04-01T05:25:52Z msg="Unable to get Docker client for version 1.43: Error response from daemon: client version 1.43 is too new. Maximum supported API version is 1.41" module=sdkclientfactory.go level=info time=2024-04-01T05:25:52Z msg="Unable to get Docker client for version 1.44: Error response from daemon: client version 1.44 is too new. Maximum supported API version is 1.41" module=sdkclientfactory.go level=info time=2024-04-01T05:25:52Z msg="Registered transformation function with threshold 1.0.0." level=error time=2024-04-01T05:25:52Z msg="Error getting ECS instance credentials from default chain: NoCredentialProviders: no valid providers in chain. Deprecated.\n\tFor verbose messaging see aws.Config.CredentialsChainVerboseErrors" level=info time=2024-04-01T05:25:52Z msg="Image excluded from cleanup" image="amazon/amazon-ecs-pause:0.1.0" level=info time=2024-04-01T05:25:52Z msg="Image excluded from cleanup" image="amazon/amazon-ecs-pause:0.1.0" level=info time=2024-04-01T05:25:52Z msg="Image excluded from cleanup" image="amazon/amazon-ecs-agent:latest" level=info time=2024-04-01T05:25:52Z msg="Remaining memory" remainingMemory=3871 level=info time=2024-04-01T05:25:52Z msg="Initializing host resource manager, initialHostResource" initialHostResource=m

How can i do with this case to use aws optimize gpu ami for ecs

Thank for your help!

1 Answer
1

Here's what you can do:

Create an IAM role with the necessary permissions:

Go to the IAM console. Create a new IAM role. Attach the appropriate policies that grant permissions to interact with ECS in the ap-northeast-1 region. Make sure to also attach the AmazonEC2ContainerServiceforEC2Role managed policy to the role, as it provides the necessary permissions for ECS. Attach the IAM role to the EC2 instance:

Go to the EC2 console. Select the EC2 instance you want to attach the IAM role to. Click on "Actions" > "Instance Settings" > "Attach/Replace IAM Role." Choose the IAM role you created earlier and attach it to the instance. Once the IAM role is attached to the EC2 instance, it should have the necessary credentials to authenticate with AWS services, and you should no longer encounter the "NoCredentialProviders" error.

After resolving the credential issue, you can continue with your deployment to register the EC2 instance with your ECS cluster using the GPU-optimized AMI.

profile picture
EXPERT
answered 12 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions