AWS CLI - CodeDeploy Create-Deployment has Unknown Options error - amazon-web-services

I have a normal CodeDeploy package which is able to deployed using the Console without any issues, but when using the CLI, I get a weird error.
aws deploy create-deployment --application-name MyApp --s3-location bucket=mybucket,key=My.Zip.1.1.1.zip,bundleType=zip --deployment-group-name MyDeploymentGroup --deployment-config-name CodeDeployDefault.OneAtATime --description "This throwns an error"
Running the above, I get the following returned:
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: bundleType=zip, key=My.Zip.1.1.1.zip
Weird, since the help does say you need bundleType and key in the s3-location parameter. Just as a test, I remove these unknown options:
aws deploy create-deployment --application-name MyApp --s3-location bucket=mybucket --deployment-group-name MyDeploymentGroup --deployment-config-name CodeDeployDefault.OneAtATime --description "This throwns an error"
Which returns:
--s3-location must specify bucket, key and bundleType.
So, now you know of these options and require them? What is going on here? Am I missing something obvious?

When I ran the code you provided, I got the following returned:
$ aws --version
aws-cli/1.10.60 Python/2.7.11 Darwin/15.6.0 botocore/1.4.50
$ aws deploy create-deployment --application-name ...snip
An error occurred (ApplicationDoesNotExistException) when calling the CreateDeployment operation: No application found for name: MyApp
And this(AWS server side error) is the expected behaviour(I guess).
One possibility that your CLI raised the validation error is that your AWS CLI is out of date.
Which version is your AWS CLI?

I had the same issue. It seemed to be related to the version of PowerShell. It worked on v5, but not on v4.
To fix it, I just put double quotes around the s3-location argument:
aws deploy create-deployment --application-name MyApp --s3-location "bucket=mybucket,key=My.Zip.1.1.1.zip,bundleType=zip" --deployment-group-name MyDeploymentGroup --deployment-config-name CodeDeployDefault.OneAtATime --description "This throwns an error"

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 :)

How to see the deployment progress via aws cli

I created a deployment using AWS cli:
aws deploy create-deployment --application-name systest1 --deployment-group-name TEST --s3-location bucket=artifacts,bundleType=zip,key=APP.zip
and I got the out as
{
"deploymentId": "d-559F8S41O"
}
How can I see the status of the deployment?? I believe
aws deploy get-deployment
will show us the status but it will not show continuous progress. Actually, I am using AWS cli so use don't have to go on AWS console and check the deployment status instead he will get the result on gitlab-ci output only. Any suggestion??
Use the below CLI command to get the status:
aws deploy get-deployment --deployment-id d-52EZVE6PC --query "deploymentInfo.[status, creator]" --output text

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

Why does setting triggers for CodeDeploy deployment group fail with InvalidTriggerConfigException?

I'm trying to set up triggers with awc cli.
According to documentation:
http://docs.aws.amazon.com/codedeploy/latest/userguide/how-to-notify-edit.html
http://docs.aws.amazon.com/codedeploy/latest/APIReference/API_UpdateDeploymentGroup.html
aws deploy update-deployment-group --application-name NAME --deployment-config-name CodeDeployDefault.OneAtATime --current-deployment-group-name TEST --trigger-configurations '[{"triggerName":"TEST-CD","triggerTargetArn":"my:arn","triggerEvents":["DEPLOYMENT_SUCCESS|DEPLOYMENT_FAILURE|INSTANCE_FAILURE"]}]'
aws deploy update-deployment-group --application-name NAME --deployment-config-name CodeDeployDefault.OneAtATime --current-deployment-group-name TEST --trigger-configurations '[{"triggerName":"TEST-CD","triggerTargetArn":"my:arn","triggerEvents":["DEPLOYMENT_SUCCESS"]}]'
aws deploy update-deployment-group --application-name NAME --deployment-config-name CodeDeployDefault.OneAtATime --current-deployment-group-name TEST --trigger-configurations '[{"triggerName":"TEST-CD","triggerTargetArn":"my:arn","triggerEvents":{"DEPLOYMENT_SUCCESS"}}]'
But i'm not able to do this. Reciving following errors:
A client error (InvalidTriggerConfigException) occurred when calling
the UpdateDeploymentGroup operation: Invalid Trigger event type
Here is how to do it properly:
https://forums.aws.amazon.com/thread.jspa?threadID=228103

getting an error when doing code deploy

I'm running the following command to do a code deploy from jenkins to EC2 server
aws deploy create-deployment --application-name $APPNAME --s3-location bucket=$S3BUCKET,key=chefdeployment.zip,bundleType=zip --deployment-group-name $DEPLOYMENTGROUPNAME --deployment-config-name CodeDeployDefault.HalfAtATime --description "Deploy" --region us-east-1 --profile $PROFILE --output text
I am getting the following error
A client error (InstanceIdRequiredException) occurred when calling the GetDeploymentInstance operation: Instance ID is Missing.
Has anyone seen this error before?
InstanceIdRequiredException doesn't seem to be an exception that we throw when call create-deployment from CLI.
The exception seems to be thrown when you call get-deployment-instance, and instanceId is required. Here is the doc for reference: http://docs.aws.amazon.com/cli/latest/reference/deploy/get-deployment-instance.html