How to run `AWS sam` command on ubuntu? - amazon-web-services

I am using AWS sam to package and deploy my lambda functions. But I found the sam command doesn't work well in ubuntu linux.
Below is the output of sam package command from ubuntu-16.04. It looks like the command arguments error but the same command can be run on Mac. I don't know what wrong with this command.
$ sam package --template-file sam.yaml --s3-bucket mybucket --output-template-file packaged.yaml
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
aws: error: argument operation: Invalid choice, valid choices are:
...
$ sam --version
SAM CLI, version 0.16.0

It turns out that the problem was that the awscli version was too old. Solved it by upgrading awscli since it is used underneath.

Related

AWS coiffure stopped working. CI/CD gitlab.com

I'm using GitLab CI tool and was using this script for a few months with no problems at all:
- curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
- unzip awscli-bundle.zip
- ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
- aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
- aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
- aws configure set region us-east-1
...
This worked fine before, but yesterday it started to give this error on aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID line:
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
usage:
Note: AWS CLI version 2, the latest major version of the AWS CLI, is now stable and recommended for general use. For more information, see the AWS CLI version 2 installation instructions at: https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
aws: error: the following arguments are required: value
I'm sure I'm using awscli1
Would be very grateful for some help :)

AWS CLI EC2: option modify-default-credit-specification not working

It says in the EC2 userguide that you can change the t2/t3/t3a default-credit-specification for your AWS account Link Here.
When I run the command aws ec2 modify-default-credit-specification --region us-east-1 --instance-family t2 —-cpu-credits unlimited, it says Invalid choice: 'modify-default-credit-specification'. How do I change the default specification of t2/t3/t3a instances
Try updating your aws cli to the latest version.
$ aws --version
aws-cli/1.14.44 Python/3.6.8 Linux/4.15.0-72-generic botocore/1.8.48
$ aws ec2 modify-default-credit-specification
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
aws: error: argument operation: Invalid choice, valid choices are:
...
but
$ ~/.local/bin/aws --version
aws-cli/1.16.309 Python/3.6.8 Linux/4.15.0-72-generic botocore/1.13.45
$ ~/.local/bin/aws ec2 modify-default-credit-specification
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
aws: error: the following arguments are required: --instance-family, --cpu-credits
This command will work in AWS CLI version 2.
Link to download/install -> https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-windows.html'
Command to check default CPU Level credits:-
aws ec2 --region us-west-2 get-default-credit-specification --instance-family t3
Command to disable at account level for Oregon Region:
aws ec2 modify-default-credit-specification --region us-west-2 --instance-family t3 --cpu-credits standard

s3 intelligent tiering, getting storage-class invalid choice at CLI

Update - how to upgrade aws cli? my attempts failed.
I get the following.
I've tried different regions and intelligent tiering works ok in the management console UI. But using the CLI I get:
$ aws s3 cp aws_aliases.sh --storage-class INTELLIGENT_TIERING s3://snap2web1
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
aws: error: argument --storage-class: Invalid choice, valid choices are:
STANDARD | REDUCED_REDUNDANCY
STANDARD_IA
I tried updating my aws cli but that didn't help:
$ aws --version
aws-cli/1.14.44 Python/3.6.8 Linux/4.15.0-65-generic botocore/1.8.48
$ pip install --upgrade awscli
Collecting awscli
...
$ aws --version
aws-cli/1.14.44 Python/3.6.8 Linux/4.15.0-65-generic botocore/1.8.48
I tried upgrading my aws version from 1.44 to 1.61 but
$ pip install --upgrade awscli
didn't do it.
I then removed awscli and reinstalled it but I still get 1.44
How to upgrade ?
Update: After update (sudo snap install aws-cli --classic):
$ aws --version
aws-cli/1.16.148 Python/3.6.7 Linux/4.15.0-65-generic botocore/1.12.138
You may be using an outdated version of the cli, please upgrade. What version are you using?
aws --version
Support for intelligent tier was added in version 1.16.61 of the aws cli as can be seen in the Github project.

AWS sam deploy return error invalid choice

I'm following the instruction here to use AWS CodeDeploy to push code from GitHub to AWS.
I run into this error:
$ sam deploy -template-file packaged.yaml –stack-name mySafeDeployStack –capabilities CAPABILITY_IAM
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
aws: error: argument subcommand: Invalid choice, valid choices are:
push | register
deregister | install
uninstall
I have previously run this command successfully:
$ sam package --template-file template.yaml --s3-bucket my-bucket --output-template-file packaged.yaml
Uploading to ... (100.00%)
Successfully packaged artifacts and wrote output template to file packaged.yaml.
Execute the following command to deploy the packaged template
aws cloudformation deploy --template-file .../packaged.yaml --stack-name <YOUR STACK NAME>
$ sam --version
SAM CLI, version 0.6.0
I've tried the recommended command:
aws cloudformation deploy ...
but it returns the same error.
It looks like you're using single dashes for the flags when they require two. The sam package command succeeded since you used two dashes for it.
This should work:
sam deploy --template-file packaged.yaml --stack-name mySafeDeployStack --capabilities CAPABILITY_IAM

How to resolve this error on a Kubernetes Installation on AWS?

I'm trying to install Kubernetes (first time) on AWS according to this tutorial http://kubernetes.io/docs/getting-started-guides/aws/#prerequisites
I can use the AWS CLI but after running the following command:
export KUBERNETES_PROVIDER=aws; curl -sS https://get.k8s.io | bash
Then I get this error:
Unpacking kubernetes release v1.3.0
Creating a kubernetes on aws...
... Starting cluster in us-west-2a using provider aws
... calling verify-prereqs
... calling kube-up
Starting cluster using os distro: jessie
usage: aws [options] <command> <subcommand> [parameters]
aws: error: argument subcommand: Invalid choice, valid choices are:
list
Uploading to Amazon S3
+++ Staging server tars to S3 Storage: kubernetes-staging-a9b7435c8fc7b6c3d3e26fdd5b84aaae/devel
usage: aws [options] <command> <subcommand> [parameters]
aws: error: argument --region: expected one argument
any help/insight appreciated..
I had the same issue; it turned out I had pip install aws not pip install awscli. After uninstalling aws and installing awscli I was good to go.
Seems region is missing from environment vars.
Below example is env vars for Singapore region
export KUBE_AWS_ZONE=ap-southeast-1a
export NUM_NODES=2
export MASTER_SIZE=t2.micro
export NODE_SIZE=t2.micro
export AWS_S3_REGION=ap-southeast-1
export AWS_S3_BUCKET=mudrii-kubernetes-artifacts
export KUBE_AWS_INSTANCE_PREFIX=k8s