I have a collection of CloudFormation templates that I'm using to create new resources but I also have a small percentage of AWS resources that were created outside of CF that I now want to import into CF. I know how to import existing resources into CF via the AWS dashboard but I want to do it with the CLI instead.
This is the documentation I thought would help but it appears to be out of date as I don't have a "--resources-to-import" option when I run aws cloudformation create-stack help. An up-to-date example would be very helpful if this is even possible via the command-line.
In step 4 of the CLI documentation on that page, it is actually a create-change-set call instead of a create-stack call:
aws cloudformation create-change-set --change-set-type IMPORT --resources-to-import
Related
I’d like to import an existing CloudFormation template. I came across a tutorial [1] to do this for CloudFormation. I was wondering, is there something similar for Terraform?
[1] Import or migrate an existing AWS CloudFormation template - AWS Cloud Development Kit (CDK)
Sadly, there is not such functionality.
I am getting Requires capabilities : [CAPABILITY_IAM] error when creating a stack on cloudformation.
Now I know we need to execute the command to create the stack with following parameter --capabilities CAPABILITY_IAM when using AWS CLI.
Question is how do I change the setting or solve this issue when using cloudformation from aws console so that I am able to create the stack by uploading the script using web console.
In the review pages you have option to allow that:
I noticed the aws console has "Create Template from Instance" option. Is there a boto3 or aws cli equivalent?
I want to create a launch template using python + boto3 from a given instance-id. However I don't want to go through all the minute details used to create the instance.
I've found the documentation for create_launch_template but did not see anything similar to this option.
I could not find any cli or boto3 api equivalent to "create template from instance" console option.
I'm creating a new user pool in AWS Cognito. As you might know, CF support is missing for a lot of the features in Cognito, so I´ve resorted to using the CLI for Cognito. But I still want to use CloudFormation for other resources like API Gateway that will need to reference the new user pool.
Is there any way I can create parameters with the CLI that I can use in CloudFormation?
Yes, if you have Parameters in your template, then you can use the CloudFormation Deploy command to do exactly this.
For example, you can call aws cloudformation deploy --template-file <file_path> --stack-name <stack_name> --parameter-overrides ParameterKey1=ParameterValue1 ParameterKey2=ParameterValue2 ... where <file_path> is the path to your CloudFormation Template, and <stack_name> is the name of your CloudFormation Stack. If this stack doesn't exist yet, Deploy will create it, but if it does exist, Deploy will update it.
Is there any way to use a simple JSON file (of my instance details) to configure a Cloud Formation template?
That's basically what a CloudFormation template provides you. Since it is a template, you can also pass in parameters as variables.
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html
Details on passing parameters from a config file:
https://aws.amazon.com/blogs/devops/passing-parameters-to-cloudformation-stacks-with-the-aws-cli-and-powershell/
You can have CFT parameters populated however you like. If you want to run / load the CFT from AWS console - add the parameters as either default or options within the CFT and choose them while creating the stack.
If you want to load them from a properties file - you can use any programming language of your choice to do so. A bash script that loads the properties or whatever, it's upto you and your use case. If you are using AWS cli to run the CFT use bash shell or power shell, if you are using AWS SDK to run your CFT - use the same language as your SDK etc.
If you are using just aws cli, you can do something like this with a json parameters file:
aws cloudformation create-stack --stackname startmyinstance
--template-body file:///some/local/path/templates/startmyinstance.json
--parameters file:///some/local/path/params/startmyinstance-parameters.json