Posts

Showing posts with the label Aws Cli

AWS CLI - All Commands Return Unknown Output Type: [None]

Answer : $aws configure press Enters see the "Default output format [None]:" input one of "json, text or table "(all in lower case) after that rerun your command. My ~/.aws/config was somehow in a bad state, there were multiple declarations for the same setting under a single role header. Editing the file manually fixed my issue. The info under Configuration Settings and Precedence https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html led me to the right place.

AWS Sts Assume Role In One Command

Answer : Finally, a colleague shared with me this awesome snippet that gets the work done in one go: eval $(aws sts assume-role --role-arn arn:aws:iam::123456789123:role/myAwesomeRole --role-session-name test | jq -r '.Credentials | "export AWS_ACCESS_KEY_ID=\(.AccessKeyId)\nexport AWS_SECRET_ACCESS_KEY=\(.SecretAccessKey)\nexport AWS_SESSION_TOKEN=\(.SessionToken)\n"') Apart from the AWS CLI, it only requires jq which is usually installed in any Linux Desktop. You can store an IAM Role as a profile in the AWS CLI and it will automatically assume the role for you. Here is an example from Using an IAM role in the AWS CLI - AWS Command Line Interface: [profile marketingadmin] role_arn = arn:aws:iam::123456789012:role/marketingadminrole source_profile = user1 This is saying: If a user specifies --profile marketingadmin Then use the credentials of profile user1 To call AssumeRole on the specified role This means you can simply call a command like this and...

AWS Amplify/CLI Vs AWS Mobile Hub

Answer : Use the Amplify CLI going forward, it's more flexible architecture that allows a comprehensive feature set. See the information in this post: Existing Mobile Hub projects continue to work without requiring any app changes. If you’re using the AWS Mobile CLI for existing projects, you can also continue to use that older CLI. However, going forward, new features will be added to the AWS Amplify CLI toolchain which does not use Mobile Hub. If you’re building a new mobile or web app, or adding cloud capabilities to brownfield apps, use the new AWS Amplify CLI. The new Amplify CLI will allow you to take advantage of all the new features outlined in this blog, as well as the rich CloudFormation functionality to unlock more workflows and future tooling. Section: Existing tooling , https://aws.amazon.com/blogs/mobile/announcing-the-aws-amplify-cli-toolchain/

Check If File Exists In S3 Using Ls And Wildcard

Answer : (re-drafted from comment as it appears this answered the question) I myself tried, and failed to use wildcards in the aws-cli, and according to the docs, this is not currently supported. Simplest (though least efficient) solution would be to use grep: aws s3 ls s3://my-bucket/folder/ | grep myfile Alternatively, you could write a short python/other script to do this more efficiently (but not in a single command) aws s3 ls does not support globs, but sync does and has a dry run mode. So if you do this (from an empty directory) you should get the results you want: aws s3 sync s3://my-bucket . --exclude "*" --include "folder/*myfile*" --dryrun It will produce lines like this for matching files: (dryrun) download s3://my-bucket/folder/myfile.txt to folder/myfile.txt (dryrun) download s3://my-bucket/folder/_myfile-foo.xml to folder/_myfile-foo.xml S3 doesn't support wildcard listing. You need to list all the files and grep it. aws s3 ls s3:...

Awscli Version 2 On Alpine Linux

Answer : Actually with a bit a effort it is possible to run AWS CLI v2 on Alpine: FROM alpine:3.11 ENV GLIBC_VER=2.31-r0 # install glibc compatibility for alpine RUN apk --no-cache add \ binutils \ curl \ && curl -sL https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub -o /etc/apk/keys/sgerrand.rsa.pub \ && curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-${GLIBC_VER}.apk \ && curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-bin-${GLIBC_VER}.apk \ && curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VER}/glibc-i18n-${GLIBC_VER}.apk \ && apk add --no-cache \ glibc-${GLIBC_VER}.apk \ glibc-bin-${GLIBC_VER}.apk \ glibc-i18n-${GLIBC_VER}.apk \ && /usr/glibc-compat/bin/localedef -i en_US -f UTF-8 en_US.UTF-8 \ && curl -sL https://awscli.amazonaws.com/...