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.
Related
I am trying to build a pipeline in gitlab which is using their provided gl-cloudformation Template to deploy Infrastructure to aws:
https://gitlab.com/gitlab-org/cloud-deploy/-/blob/master/aws/src/bin/gl-cloudformation
I am running into a problem with creating IAM roles since cloudformation is needing extra confirmation to deploy stacks which create IAM resources. Normally i would just run aws create-stack --capabilities CAPABILITY_NAMED_IAM but since i am useing their template i can't.
Anyone got any experience with running gitlab and cloudformation?
This is not possible with that image. You must either use different CI Image or do not add custom name for the IAM resoucre (let the AWS generate name).
I was testing the AWS SAM functionality and encountered an issue.
If by manually delete a resource that was originally created by the SAM template, then subsequent SAM deployment will fail. I do understand that deleting resource manually that was created by SAM is not a good practice. But this was just a test only
Error
Is there any way to fix this?
AWS SAM uses Cloudformation underneath to create various resources.
How do I update an AWS CloudFormation stack that's failing because of a resource that I manually deleted?
If you delete a resource from an AWS CloudFormation stack, then you must remove the resource from your AWS CloudFormation template. Otherwise, your stack fails to update, and you get an error message.
similar post : Function not found after manually deleting a function in a SAM CloudFormation stack
Which services can be managed by the AWS SAM (Serverless Application Model) framework?
AWS Docs seem to list contradicting information:
https://aws.amazon.com/serverless/ lists plenty of services as serverless, incl. Lambda, Fargate, ..., SNS, SQS, ... DynamoDB, S3.
SAM resource reference lists only: Api, Application, Function, HttpApi, LayerVersion, SimpleTable, StateMachine.
Yet, I cannot find any mention in the SAM docs on how to create an S3 bucket.
An example doubt is - can I have an S3 bucket created using SAM framework?
Can SAM deploy to Fargate too?
You can add any CloudFormation component as part of your SAM config file. As noted in the SAM developer guide:
AWS SAM templates are an extension of AWS CloudFormation templates, with some additional components that make them easier to work with. For the full reference for AWS CloudFormation templates, see AWS CloudFormation Template Reference in the AWS CloudFormation User Guide.
I am using CloudFormation with SAM to deploy a stack which contains:
S3 Bucket
Cognito
AWS::Serverless::Api
AWS::Serverless::Function (authorizers + microservices, Type: Api and endpoints of the API Gateway)
Log Groups
To deploy my stack, I first run aws cloudformation package to package the lambda and then run aws cloudformation deploy to deploy the generated stack. This is working.
My goal now is to be able to update a microservice without deploying the entire stack (not building authorizers and other microservices), similar to serverless deploy function in the Serverless framework. This should preferably be one reusable template that uses a macro or just replaces text in the file.
The problem I am facing with this:
Running aws lambda update-function-code requires the lambda to be redeployed
To redeploy the lambda I have to declare AWS::Serverless::Function. For the function to be part of the API Gateway, AWS::Serverless::Api must be declared as well.
Declaring AWS::Serverless::Api requires all the other functions to be defined or they will be removed from the API Gateway.
I feel like I am stuck here and have not found other options of achieving my goal.
Since you're using SAM, I'd recommend deploying and updating your application using the sam cli commands.
You can run
sam build
sam package
sam deploy
When you run sam deploy, it deploys your application, but all subsequent sam deploy commands will update your existing cloudformation stack with only the appropriate resources that need updating.
If you opt for keeping with the standard Cloudformation cli commands, you could use the aws cloudformation update-stack command so that you're not re-deploying an entire new stack.
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