Questions tagged [aws-cli]

aws help

The AWS Command Line Interface (CLI) is a unified tool to manage AWS services. Multiple AWS services can be controlled via the command line and various actions can be automated through this tool.

47 questions
21
votes
6 answers

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 s3://mybucket --recursive --human-readable…
Kyle Steenkamp
  • 1,172
  • 1
  • 9
  • 18
16
votes
6 answers

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 command. I've installed aws via apt-get: $ aws…
kenorb
  • 8,011
  • 14
  • 43
  • 80
11
votes
1 answer

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 that to happen, so I'm reaching out here. Use…
Alex
  • 4,612
  • 6
  • 29
  • 49
10
votes
2 answers

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 Run a shell script as a specific user Question Is…
Max Colledge
  • 205
  • 1
  • 2
  • 7
8
votes
1 answer

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-instances, etc... I can't seem to find one that lets me…
Alex
  • 4,612
  • 6
  • 29
  • 49
7
votes
3 answers

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 "AWS-RunPowerShellScript" --query…
kenorb
  • 8,011
  • 14
  • 43
  • 80
6
votes
2 answers

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\nAOh...xg==\r\n", "Timestamp":…
kenorb
  • 8,011
  • 14
  • 43
  • 80
6
votes
5 answers

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 --query parameters, but I'm not sure about the…
kenorb
  • 8,011
  • 14
  • 43
  • 80
5
votes
4 answers

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 when a role was last used without pretend deleting…
Uberhumus
  • 297
  • 4
  • 15
5
votes
4 answers

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-east-1 --filters Name=encrypted,Values=false…
hawkeye
  • 1,153
  • 1
  • 9
  • 14
4
votes
1 answer

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 via pip Firstly, I install Python (tried both;…
hey
  • 141
  • 1
  • 4
4
votes
3 answers

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 stated in the AWS userguide:…
Max N.
  • 413
  • 6
  • 13
3
votes
0 answers

How to override the user for ECS task via CLI?

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 is running by using --overrides parameter of aws…
kenorb
  • 8,011
  • 14
  • 43
  • 80
3
votes
2 answers

AWS CLI --profile with duration > 1h

With the AWS CLI you can assume a role using the --profile parameter: aws --profile e.g.: aws --profile admin s3 ls s3://mybucket/ That profile can be an AWS role that os to be assumed. My problem with that is…
Hugo G
  • 153
  • 4
3
votes
1 answer

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 out there for this but I have tried a few with no…
user8517
1
2 3 4