Skip to main content

Questions tagged [aws-cli]

aws <command> <subcommand> help

Filter by
Sorted by
Tagged with
21 votes
6 answers
41k views

View all AWS S3 buckets and list each buckets storage used

I have multiple AWS accounts and I need to list all S3 buckets per account and then view each buckets total size. Currently, I can only view the storage size of a single S3 bucket with: aws s3 ls ...
Kyle Steenkamp's user avatar
16 votes
6 answers
50k views

How to run a script or a command on EC2 instance via AWS CLI?

According to New EC2 Run Command news article, AWS CLI should support a new sub-command to execute scripts on remote EC2 instances. However I've checked in aws ec2 help, but I can't find the relevant ...
kenorb's user avatar
  • 7,901
11 votes
1 answer
1k views

How to set up AWS Trusted Advisor alert for Service Limit warnings?

All I want in life is for AWS to shoot me an email when any of Trusted Advisor's Service Limits go to WARN or ERROR status. I've checked their guides, tried chatting with support and no one can get ...
Alex's user avatar
  • 4,522
9 votes
1 answer
10k views

Running a command as a specific user on an ec2 using ssm

Background I want to automatically configure an EC2 via a build, using the aws cli and ssm. The (manual) setup for the container looks something like this: Create an EC2 Run a shell script as root ...
Max Colledge's user avatar
7 votes
3 answers
9k views

How to avoid output being truncated when running AWS SSM command?

I've got the following AWS CLI commands to run the PowerShell's Invoke-WebRequest command: instanceId=i-0xyz # Change this. cmdId=$(aws ssm send-command --instance-ids "$instanceId" --document-name "...
kenorb's user avatar
  • 7,901
7 votes
1 answer
21k views

How to get environment variables in ECS container?

What AWS CLI command should I be using to access the environment variables in an AWS ECS cluster's task's container? I've seen describe-cluster, list-tasks, describe-tasks, describe-container-...
Alex's user avatar
  • 4,522
6 votes
2 answers
3k views

How to find out the used Key pair name via AWS CLI?

I'm aware of get-password-data command which can display PasswordData data like: $ aws ec2 get-password-data --instance-id i-0123456789 { "InstanceId": "i-0123456789", "PasswordData": "\r\...
kenorb's user avatar
  • 7,901
6 votes
5 answers
13k views

How to list security groups for the specific instance via CLI?

I'm looking for syntax like: aws ec2 describe-security-groups --instance-id i-0xyz however, the above sub-command doesn't support --instance-id parameter. I've checked and there are --filters and --...
kenorb's user avatar
  • 7,901
5 votes
4 answers
4k views

How to see when an AWS IAM role was last used?

In AWS in the GUI you can select a role and then click on delete, then when you are prompted to approve or deny the deletion it shows you when the role was last used. I would like to be able to know ...
Uberhumus's user avatar
  • 297
5 votes
4 answers
3k views

How can I get a list of encrypted disks for instances that are running on the AWS CLI?

There is a great question here about how to get a list of encrypted disks. I'm currently using the describe-volumes command. For the record I'm currently using: aws ec2 describe-volumes --region us-...
hawkeye's user avatar
  • 1,153
4 votes
3 answers
2k views

Amazon EKS from local kubectl does not cache MFA token/session

I have set up an EKS cluster in AWS. My user-account there is secured with MFA. And I have an assumerole, that is allowed to manage my infrastructure. So I installed and configured my system as ...
Max N.'s user avatar
  • 413
4 votes
1 answer
3k views

How to install aws cli on a self-hosted azure DevOps Windows agent?

I have quite some difficulties installing aws cli on a self-hosted Azure DevOps Windows agent as part of a pipeline. Does anyone have a working solution? What I have tried so far: a) install aws cli ...
hey's user avatar
  • 141
3 votes
1 answer
8k views

How to export EC2 snapshot into S3 bucket?

I've created a snapshot of EC2 instance via: aws ec2 create-snapshot --volume-id vol-xyz In aws ec2 create-snapshot help we can read: Creates a snapshot of an EBS volume and stores it in Amazon ...
kenorb's user avatar
  • 7,901
3 votes
2 answers
2k views

List encrypted RDS snapshots using CLI

I have automated the RDS snapshot copy across the region, but the Snapshot which is encrypted gets fail to copy. I have figured a way to copy an encrypted snapshot using $ aws rds copy-db-snapshot ...
Nirbhay Singh's user avatar
3 votes
1 answer
701 views

Get tagging to work on AWS CLI

I am trying to tag commit hash and app version onto the ECS service to make it easier for developers to identify the service with the code. But I get this error + aws ecs tag-resource --resource-...
Moses Liao GZ's user avatar
3 votes
1 answer
489 views

Configure AWS cli inside chef cookbook

I am working on setting up something with S3 and Chef, I have AWS CLI installed and working but I need to figure out how to specify the access ID and the secret access key. I know there are cookbooks ...
user avatar
3 votes
2 answers
879 views

AWS CLI and a JSON file

I'm setting up my AWS CLI. To access to AWS services like EC2, I have to switch roles. I used the command aws sts assume-role, and it spit out JSON with Credentials and AssumedRoleUser, complete with ...
ahoffer's user avatar
  • 143
3 votes
2 answers
90 views

AWS CLI --profile with duration > 1h

With the AWS CLI you can assume a role using the --profile parameter: aws --profile <profile_name> <service> <command> e.g.: aws --profile admin s3 ls s3://mybucket/ That profile ...
Hugo G's user avatar
  • 153
3 votes
0 answers
3k views

How to override the user for ECS task via CLI? [closed]

I've got a Task Definition with parameters which executes a script using a regular user. I'd like to test the script without changing the Task Definition by overriding the default user which script ...
kenorb's user avatar
  • 7,901
3 votes
1 answer
35 views

What is the ec2 cli command to modify the minimum number of nodes in a scaling group?

I've got an ec2 autoscaling group that starts in the morning and finishes in the evening. I'd like to create a 'button' that people can click to warm up the autoscaling group to run jobs in the middle ...
hawkeye's user avatar
  • 1,153
2 votes
2 answers
2k views

Cross account access from ec2 to other accounts

Is it possible to run aws cli from ec2 to create some resources in another account without using aws_secret_key and aws_access_key?
Pzowghi's user avatar
  • 23
2 votes
1 answer
3k views

View billing and cost management dashboard info with AWS CLI

The aws web console under "Billing" (https://console.aws.amazon.com/billing/) shows "Month-to-Date Spend by Service" which breaks down costs incurred so far this month by each ...
webninja's user avatar
2 votes
1 answer
1k views

AWS SNS-SQS: Checking a subscription already exists

I've found it's a useful strategy to create relevant queues whenever a queue worker service boots. For instance, on service boot, it checks whether its queues exist already in AWS and creates them if ...
Trout's user avatar
  • 31
2 votes
1 answer
542 views

Cross Account EC2 Access from within Amazon Workspace

I have a requirement to setup a bastion host (Amazon Workspace) to connect to an ec2 instance living on a different account. As Amazon Workspaces cannot assume a role the way EC2s can, A cross ...
Inderpal Singh's user avatar
2 votes
1 answer
47 views

AWS ECR Public gives error in CLI

I am trying to push my Nest.js app to an AWS ECR in a public repo. I created an IAM user and attached AdminstratorAccess policy to it and then generated a private key. When I type the following ...
Ahmad Qayyum's user avatar
1 vote
2 answers
2k views

Is there a policy that can limit the growth of an AWS S3 buckets total size?

We have an AWS S3 bucket that accepts uploads from untrusted sources which are then processed and moved out of the bucket. Is there a Policy that can limit the growth of the bucket to some ...
David Parks's user avatar
1 vote
1 answer
760 views

How can I 'aws s3 sync' two buckets, which are located in different accounts

I'm trying to use 'aws s3 sync' on the awscli between two accounts. Account A, I own. Account B, Owned by a third party. Account B has given a user:jon on account A permission to a bucket through ...
phisshion's user avatar
1 vote
1 answer
99 views

AWS Security Group Creation Using AWS CLI

I have created a security group in AWS. I have added the ingress rule using the below command aws ec2 authorize-security-group-ingress --group-id sg-07xxxx4d --ip-protocol tcp --from-port 22 --to-...
Prashast's user avatar
1 vote
1 answer
1k views

How to fix wrong /etc/resolv.conf in kubernetes pods after creating a cluster with EKS eksctl with vpc-cni plugin?

So, i've created a kubernetes cluster in EKS with eksctl, ClusterConfig: apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: exchange-develop region: us-east-1 version: '1.19' ...
paltaa's user avatar
  • 121
1 vote
1 answer
209 views

Deploy to Ubuntu server with python script and awsebcli fails

Just yesterday everything worked fine on our AWS ElasticBeanstalk continuous deployment, but today suddenly fails with the following errors: $ pip install awsebcli -q --upgrade DEPRECATION: Python 2.7 ...
magnump0's user avatar
  • 121
1 vote
1 answer
866 views

`UnauthorizedResourceAccessException` when calling `aws workdocs create-user`

When calling aws workdocs create-user, I'm getting UnauthorizedResourceAccessException or UnauthorizedOperationException. I believe I have all of the permissions required. What could be causing this?...
claytond's user avatar
  • 121
1 vote
1 answer
27 views

Kubernetes api service unit file

i was going through the kubernetes the hard way(kelsey), i see in the API server unit file with a cluster ip range as --service-cluster-ip-range=10.32.0.0/24 \ is it a default ip range ? my VPC ...
Jithin Kumar S's user avatar
1 vote
1 answer
533 views

How to override default aws region credentials for Terraform?

I am using Terraform to create aws resources. I practiced with a single region and with my aws cli credentials being used. worked great! however when I tried to override the region in the Terraform ....
Alan-Cugler's user avatar
1 vote
1 answer
3k views

Different download speeds from AWS S3 CLI vs Console/Websites

I'm experiencing much slower traffic for the exact same files when downloading (or uploading) them via the AWS website vs. downloading them via the CLI. Is there a known reason for this? Is there ...
Uberhumus's user avatar
  • 297
1 vote
1 answer
823 views

In the AWS CLI how do I treat a special character as a string?

I'm trying to run an AWS CLI command for a resource with a ! in its name. I'm doing this from CentOS Docker instance running on my local device a MAC and if I run echo "$SHELL" it says it ...
doug's user avatar
  • 523
0 votes
1 answer
364 views

Was AWS Secrets Manager removed from AWS CLI commands?

If I enter: aws secretsmanager get-secret-value --secret-id my secret id It says invalid choice. aws: error: argument command: Invalid choice, valid choices are: and doesn't list ...
doug's user avatar
  • 523
0 votes
2 answers
2k views

How to get instance's route table id using CLI?

I'd like to find a route table id associated with the given EC2 instance. How can this be achieved using AWS CLI? I've tried to use aws ec2 describe-vpcs, but the route tables are not there. I'm ...
kenorb's user avatar
  • 7,901
0 votes
1 answer
1k views

calculating the size of objects in AWS S3 buckets

I ran into an problem recently, my AWS S3 bucket shows total size of 30 TB. However when i try to get the total size of individual folders, it is not summing up more than 2 TB. I used the below ...
Saran's user avatar
  • 3
0 votes
1 answer
413 views

Filtering AWS SQS Tags using JQ

I'm having doubts when trying to run a query with JQ. I have an SQS queue with Tags applied and when I run aws sqs list-queue-tags --region sa-east-1 --queue-url <my-url-queue> --output json | ...
Vader's user avatar
  • 466
0 votes
1 answer
582 views

AWS FARGATE ECS - Exact steps to deploy new Docker images with aws CLI

We run services in AWS FARGATE... our Docker builds are tagged before we push them to AWS with a Makefile. I committed changes to a Docker service, ran make, and I see the new Docker image tag when I ...
Mike Pennington's user avatar
0 votes
1 answer
383 views

How do I edit my AWS ASG scheduled action useing the aws CLI

my scheduled action is called training my ASG is called temp_4_jenkins as I was planning to set up a pipeline on a Jenkins on my personal account to run the CLI commands. aws application-autoscaling ...
doug's user avatar
  • 523
0 votes
2 answers
2k views

AWS-CLI : to download IAM user with policy

aws : A single command(aws-cli) to get the IAM user name with the what all permission he/she have , would be great if can be downloaded as an excel or csv ?
Jithin Kumar S's user avatar
0 votes
1 answer
60 views

How to probe all running aws ec2 instances and their sec groups, etc to generate templates?

Typically I spin up all aws ec2 instances together with all its accompanying security groups, volumes, etc ... by executing a series of aws cli commands. However when I manually use the aws console ...
Scott Stensland's user avatar
0 votes
1 answer
394 views

How to access ephemeral storage of EC2 instance?

I've got ephemeral storage setup in Scalr as part of the role. The instance is spinned up by Chef and it seems it is running fine (it's using ephemeral0 device mounted as D: drive). I've tried to use ...
kenorb's user avatar
  • 7,901
0 votes
1 answer
2k views

How to send sms to a phone number using aws sns cli? [closed]

I am using the following command. Getting Authorization error. aws sns publish --phone-number +91XXXXXXXXXX --message hello An error occurred (AuthorizationError) when calling the Publish operation: ...
Saikat Kundu Chowdhury's user avatar
0 votes
1 answer
1k views

Terraform - No Infrastructure Changes Detected

I have deployed a Cloudwatch Log Group community module to my terraform stack (sourced from https://github.com/cloudposse/terraform-aws-components) but I have spent more than a day trying to resolve ...
Don Draper's user avatar
0 votes
0 answers
63 views

aws cli shorthand json syntax

I'm trying to update the domain contacts for a couple of 100 domains using AWS cli with the shorthand syntax. This works fine for .com domains: aws route53domains update-domain-contact --domain-...
Sean C's user avatar
  • 9