Retrieve public key via AWS CLI - amazon-web-services

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

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]}"

aws transfer update-server is throwing errors

I am using terraform to create an aws sftp server and trying to use IP whitelisting to secure my server.
Terraform aws_transfer_server command supports only endpoint_types such as PUBLIC or VPC_ENDPOINT at this time. So I am using null_resource to execute an aws command to update the sftp server after it was created. The terraform snippet is below:
resource "null_resource" "update_sftp_server" {
provisioner "local-exec" {
command = <<EOF
aws transfer update-server --server-id ${aws_transfer_server.sftp.id} --endpoint-type VPC --endpoint-details SubnetIds="${join("\", \"", var.subnet_ids)}", AddressAllocationIds="${join("\", \"", toset(aws_eip.nlb.*.id))}", VPCEndpointID="${aws_vpc_endpoint.transfer.id}", VpcId="${var.vpc_id}"
EOF
}
depends_on = [aws_transfer_server.sftp, aws_vpc_endpoint.transfer]
}
This executes the below aws command
aws transfer update-server --server-id s-######## --endpoint-type VPC --endpoint-details SubnetIds="subnet-#####", "subnet-#####", AddressAllocationIds="eipalloc-######", "eipalloc-######", VPCEndpointID="vpce-#######", VpcId="vpc-#####"
But I am getting an error as below:
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: AddressAllocationIds=eipalloc-######, eipalloc-######, VPCEndpointID=vpce-######, VpcId=vpc-######, subnet-######
Can someone help me to know why this error is thrown? My environment details are below:
Terraform v0.12.28
provider.aws v3.0.0
provider.null v2.1.2
aws-cli/2.0.33 Python/3.7.7 Windows/10 botocore/2.0.0dev37
Have you tried building your argument list without spaces? So that it looks like SubnetIds="subnet-#####","subnet-#####",AddressAllocationIds="eipalloc-######","eipalloc-######",VPCEndpointID="vpce-#######",VpcId="vpc-#####" ?
Otherwise when the commandline is broken up into tokens, most of those bits will not be parsed as part of the --endpoint-details argument.

AWS Translate | Asynchronous Batch Processing | CLI | describe-text-translation-job not valid command

I have installed and configure AWS CLI both my windows 10 machine and AWS EC2 Linux machine also have one AWS translated batch job in frankfurt aws region. I am following this document for to initiate the batch translation process using CLI. https://docs.aws.amazon.com/translate/latest/dg/translate-dg.pdf
Now, suppose I am using this sample command
aws translate describe-text-translation-job --job-id xxxxxxx
I am getting this error everyplace
[ec2-user#ip-xx-xx-xx-xx ~]$ aws translate describe-text-translation-job --job-id xxxxxxx
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:
delete-terminology | get-terminology
import-terminology | list-terminologies
translate-text | help
It only show 5 valid choice other than help but as per the documentation it should be more
https://docs.aws.amazon.com/cli/latest/reference/translate/index.html#cli-aws-translate
why I am not getting these options
describe-text-translation-job
start-text-translation-job
stop-text-translation-job
list-text-translation-jobs
It was AWS CLI version problem only, I updated the version and now I get all the required methods.

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

aws cli --profile expected one parameter

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