aws cli --profile expected one parameter - amazon-web-services

I am trying to use --profile with aws-cli
$ aws s3 ls --profile profile360
Works good, but:
$ aws dynamodb scan --table-name dev_eventsApi_EventsTable --output > c:\temp\hevo.txt --profile profile360
results in
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 --output: expected one argument
I encounter cases where I have problems working with --profile
What am I doing wrong?

Define the type of output, for example, text or json. Try this.
aws dynamodb scan --table-name dev_eventsApi_EventsTable --output text --profile profile360 > c:\temp\hevo.txt

Related

Error "Unknown options: AutoImportPolicy=DELETED], AutoImportPolicy=CHANGED" while creating AWS FSx create-data-repository-association

I am getting error while adding auto-import-policy when creating AWS FSx create-data-repository-association
FSX Lustre config is:
Storage type: SSD
Deployment type: Persistent 2
Lustre version: 2.12
Success: The below command is successful
aws --region region_name fsx create-data-repository-association --file-system-id fs-xxxxxxxxxxx --batch-import-meta-data-on-create --file-system-path /ns1/ --data-repository-path s3://s3_bucket_path --s3 AutoImportPolicy={Events=[NEW]},AutoExportPolicy={Events=[NEW]}
Error: throwing error when taking multiple options in the list of the AutoImportPolicy
aws --region region_name fsx create-data-repository-association --file-system-id fs-xxxxxxxxx --batch-import-meta-data-on-create --file-system-path /ns1/ --data-repository-path s3://s3_bucket_path --s3 AutoImportPolicy={Events=[NEW,CHANGED,DELETED]}
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
Unknown options: AutoImportPolicy=DELETED], AutoImportPolicy=CHANGED
I tried the below options but none of them are successful
--s3 AutoImportPolicy={Events=['NEW','CHANGED','DELETED']}
--s3 AutoImportPolicy={Events=["NEW","CHANGED","DELETED"]}
--s3 AutoImportPolicy={Events=[NEW|CHANGED|DELETED]}
--s3 AutoImportPolicy={Events=[NEW_CHANGED_DELETED]}
but none of the above options worked
Expecting: I am expecting to create the data-repository-association whose AutoImportPolicy should be New,Changed & deleted
the issue is fixed by using the below command:
aws --region ${AWS_REGION} fsx create-data-repository-association \
--batch-import-meta-data-on-create \
--file-system-id ${fsx_id} \
--file-system-path /ns1/ \
--data-repository-path ${s3_dra} \
--s3 "AutoImportPolicy={Events=[NEW,CHANGED,DELETED]},AutoExportPolicy={Events=[NEW,CHANGED,DELETED]}"

No way to Get-Item in powershell?

So I've tried a few things now, one of which is AWS.Tools.DynamoDBv2 and nothing seems to work.
AWS CLI works in powershell to an extent, for example, the command "aws ec2 describe-instances..." works. However, "aws dynamodb get-item --table-name --key "{"primary-key":{"S":"myitem"}}" does not.
It returns the error stating that "{"primary-key":{"S":"myitem"}}" is an unknown option.
What am I doing wrong? Any help is appreciated.
aws dynamodb get-item --table-name --key "{"primarykey":{"S":"myitem"}}
aws :
At line:1 char:1
+ aws dynamodb get-item --table-name <mytable> --key "{ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
Unknown options: primary-key:{S:myitem}}
Edit:
Thanks for the help! This was really grinding my gears! As Abraham Zinala suggested, single quotes were necessary around the whole key object. Also, backslashes inside were necessary too:
--key '{\"primarykey\":{\"S\":\"myitem\"}}'
As #AbrahamZinala suggested, single quotes were necessary around the whole key object. Also, backslashes inside were necessary too:
--key '{\"primarykey\":{\"S\":\"myitem\"}}'
Also, for what it's worth, if using string interpolation, it would have to look like this:
--key '{\`"$primarykey\`":{\`"S\`":\`"$myitem\`"}}'

Retrieve public key via AWS CLI

I tried to retrieve the public key content via aws cli following https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/describe-key-pairs.html. But it didn't work.
aws ec2 describe-key-pairs --key-name mykey --include-public-key
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
Unknown options: --include-public-key

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

Dynamo DB AWS cli getting error

C:\Users\abhij\.aws\model>aws dynamodb put-item --table-name weatherstation_data --item '{"station_id":{"S":"000001"},"dateandtime" : {"S": "2015/12/25 00:00"},"temperature": {"N" : "0"}}' --profile loadmin
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
Unknown options: {S:, 2015/12/25 00:00},temperature:, {N, :, 0}}', :
You need to remove or escape all the whitespace in the JSON portion of the command. This is a common problem, which is why most of the examples in the aws dynamodb CLI tool docs show the use of a JSON file instead, like so:
aws dynamodb put-item --table-name weatherstation_data --item file://item.json --profile loadmin
Nevermind its the windows CMD thats giving the problem ran the same in linux it gives back the output
aws dynamodb put-item --table-name weatherstation_data --item '{"station_id":{"S":"000001"},"dateandtime" : {"S": "2015/12/25 00:00"},"temperature": {"N" : "0"}}' --profile loadmin