widdix / cfn-create-or-update Goto Github PK
View Code? Open in Web Editor NEWCreate or update CloudFormation stack also if no updates are to be performed.
License: MIT License
Create or update CloudFormation stack also if no updates are to be performed.
License: MIT License
After a CloudFormation stack fails to create, it can no longer be used but is not deleted by the plugin. This causes all future updates to fail with a " is in ROLLBACK_COMPLETE state and can not be updated." error.
I'm currently parsing AWS CLI output to ignore No updates are to be performed from the error output while failing on anything else. It's a hack, so cfn-create-or-update
is very welcome. I made a "universal" updating script to keep Parameters and Capabilities the same for when I'm only updating the template. It currently works something like this:
# A previous step uploads template file to $S3CfnSource ...
CFN_STACK_JSON="$( aws --region "${REGION:?}" cloudformation describe-stacks --stack-name "${CFN_STACK:?}" | jq -M '.Stacks[0] | {Parameters:.Parameters,Capabilities:.Capabilities} | del(.Parameters[].ParameterValue) | .Parameters[] |= .+ {UsePreviousValue: true}' )"
aws --region "${REGION:?}" \
cloudformation \
update-stack \
--stack-name "${CFN_STACK:?}" \
--template-url "https://s3.amazonaws.com/${S3CfnSource:?}/${CFN_SOURCE:?}" \
--cli-input-json "${CFN_STACK_JSON:?}"
Because it's possible to have a stack without parameters or capabilities, I can use --cli-input-json
to pass when I do have values and the input will be valid even when the JSON does not contain values for those items. If you could include support for --cli-input-json
, I would be able to drop your script in place and remove the nonsense I currently use to parse the error output. Thanks!
Works like a dream, however it will return success the moment it it performs the function with aws. Any interesting in extending/adding a flag, that will tell it to not return until the action against the stack is a success?
Hey,
great work until now but I found that the wait parameter does not work as its ignored in cli.js
. This is probably due to a missing assignment in the cli.js
.
Adding:
if (has('wait')) {
args.wait = string('wait');
}
In line 125 of cli.js
will probably solve the issue.
Thanks
Experiencing this issue when I'm running multiple create or updates concurrently.
Resource is not in the state stackUpdateComplete Throttling: Resource is not in the state stackUpdateComplete at Request.extractError (/usr/lib/node_modules/cfn-create-or-update/node_modules/aws-sdk/lib/protocol/query.js:47:29) at Request.callListeners (/usr/lib/node_modules/cfn-create-or-update/node_modules/aws-sdk/lib/sequential_executor.js:105:20) at Request.emit (/usr/lib/node_modules/cfn-create-or-update/node_modules/aws-sdk/lib/sequential_executor.js:77:10) at Request.emit (/usr/lib/node_modules/cfn-create-or-update/node_modules/aws-sdk/lib/request.js:673:14) at Request.transition (/usr/lib/node_modules/cfn-create-or-update/node_modules/aws-sdk/lib/request.js:22:10) at AcceptorStateMachine.runTo (/usr/lib/node_modules/cfn-create-or-update/node_modules/aws-sdk/lib/state_machine.js:14:12) at /usr/lib/node_modules/cfn-create-or-update/node_modules/aws-sdk/lib/state_machine.js:26:10 at Request.<anonymous> (/usr/lib/node_modules/cfn-create-or-update/node_modules/aws-sdk/lib/request.js:38:9) at Request.<anonymous> (/usr/lib/node_modules/cfn-create-or-update/node_modules/aws-sdk/lib/request.js:675:12) at Request.callListeners (/usr/lib/node_modules/cfn-create-or-update/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
The reality is, the cloudformation stack was created/updated successfully - but due to the CLI exiting non-zero, our pipeline task fails.
through to exactly pinned dependency versions in the package.json npm audit fix can't do its work for sub-dependent security vulnerabilities in proxy-agent.
could you please change the way you require dependent packages to ^, ~ or *?
I am getting the following:
cfn-create-or-update --stack-name wordpress-ha --template-body file://wordpress-ha-aurora.yaml --region us-east-1
Parameters: [BlogAdminPassword, DomainName, ParentVPCStack, CloudFrontAcmCertificate, BlogAdminEMail, ElbAcmCertificate] must have values ValidationError: Parameters: [BlogAdminPassword, DomainName, ParentVPCStack, CloudFrontAcmCertificate, BlogAdminEMail, ElbAcmCertificate] must have values
at Request.extractError (/usr/local/lib/node_modules/cfn-create-or-update/node_modules/aws-sdk/lib/protocol/query.js:47:29)
at Request.callListeners (/usr/local/lib/node_modules/cfn-create-or-update/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
at Request.emit (/usr/local/lib/node_modules/cfn-create-or-update/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/usr/local/lib/node_modules/cfn-create-or-update/node_modules/aws-sdk/lib/request.js:673:14)
at Request.transition (/usr/local/lib/node_modules/cfn-create-or-update/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/usr/local/lib/node_modules/cfn-create-or-update/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /usr/local/lib/node_modules/cfn-create-or-update/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request. (/usr/local/lib/node_modules/cfn-create-or-update/node_modules/aws-sdk/lib/request.js:38:9)
at Request. (/usr/local/lib/node_modules/cfn-create-or-update/node_modules/aws-sdk/lib/request.js:675:12)
at Request.callListeners (/usr/local/lib/node_modules/cfn-create-or-update/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
I guess it's asking to provide the required parameters. Is there any option to pass the option such "use the existing ones"?
The HTTP_PROXY and HTTPS_PROXY environment variables don't seem to be used like with the AWS CLI.
http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/node-configuring-proxies.html
sudo /usr/bin/cfn-create-or-update --stack-name sample --template-body file://Tomcat-app-cfn.yaml --region us-east-1 --parameters ParameterKey=KeyName,ParameterValue=rg-newkey ParameterKey=AppURL,ParameterValue=http://localhost/app.war ParameterKey=VPCId,ParameterValue=vpc-12345 ParameterKey=EC2Subnets,ParameterValue="subnet-123456,subnet-789109"
When I run this command it throws error _parameters[3] ParameterKey, ParameterValue or UsePreviousValue expected
_ for EC2Subnets Parameter. whereas the aws cloudformation create-stack command works with same value.
Please let me know what's the right syntax to pass array or list parameter values.
Running a script with --wait after upgrade to 1.4.0 gives the following result. No issues running this command in 1.3.0.
Command:
cfn-create-or-update --stack-name whatever --template-body file://dist/cloud-formation/thing.yml --capabilities CAPABILITY_NAMED_IAM --wait
also tried --wait true
and --wait "true"
All returned the same error.
YError: Invalid first argument. Expected boolean or string but received function.
at argumentTypeError (/home/travis/.nvm/versions/node/v8.12.0/lib/node_modules/cfn-create-or-update/node_modules/yargs/lib/argsert.js:65:9)
at parsed.optional.forEach (/home/travis/.nvm/versions/node/v8.12.0/lib/node_modules/cfn-create-or-update/node_modules/yargs/lib/argsert.js:47:39)
at Array.forEach (<anonymous>)
at argsert (/home/travis/.nvm/versions/node/v8.12.0/lib/node_modules/cfn-create-or-update/node_modules/yargs/lib/argsert.js:42:21)
at Object.version (/home/travis/.nvm/versions/node/v8.12.0/lib/node_modules/cfn-create-or-update/node_modules/yargs/yargs.js:778:5)
at Object.exports.parse (/home/travis/.nvm/versions/node/v8.12.0/lib/node_modules/cfn-create-or-update/lib/arg.js:28:6)
at Object.<anonymous> (/home/travis/.nvm/versions/node/v8.12.0/lib/node_modules/cfn-create-or-update/cli.js:20:30)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.