Let’s say you have an account in Amazon Web Services (AWS) and got some instance running under an Elastic Container Services (ECS).
You had it running OK, until suddenly got the bills charging for the CloudWatch usage.
You go in the AWS console and checked the way to disable the Container Insight for the running ECS, and found out there is no button for that.
And need to use aws-cli command as below to disable it.
aws ecs update-cluster-settings --cluster ${clustername} --settings name=containerInsights,value=disabled --region ${AWS_REGION}
And then realised you don’t have aws-cli to run in local at the moment.
Here is how to install the aws-cli in the local machine and get the AWS_SECRET_KEY for the first time.
You start to install it with the following instruction.
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target
Then verify the installation is correct with
which aws
it correct it would return the following string
/usr/local/bin/aws
and also
aws --version
aws-cli/2.1.13 Python/3.7.4 Darwin/19.6.0 exe/x86_64 prompt/off
After that you need to configure it for the first time using the following command
aws configure
it will prompt to enter the AWS ID, AWS SECRET KEY and region.
You can find this information from the AWS IAM -> Roles -> Security Credentials.
Once logged,
it will create a file under the following folder
~/.aws/config
[default]
region = Singapore
output = json
~/.aws/credential
aws_access_key_id = xxx
aws_secret_access_key = yyyy
after that you can use to disable the container insight with the following command
export AWS_REGION=ap-southeast-1
export clustername=wp-namran
aws ecs update-cluster-settings --cluster ${clustername} --settings name=containerInsights,value=disabled --region ${AWS_REGION}
response
Verify again at the console.
Done, that’s all for now.
refs:
https://docs.aws.amazon.com/cli/latest/userguide/cli-services-iam-create-creds.html
https://ecsworkshop.com/container_insights/cleanup/