Photo by Eberhard Grossgasteiger
This week we're going to talk about CloudFormation which is what we talked about in last week's Elastic Beanstalk blog that is used under the hood. After that, I also have a small introduction to CloudFront. Before I spoil anything else, let's get started.
This week we're going to talk about CloudFormation in AWS.
What is CloudFormation? It way for declaring what AWS infrastructure you want provision in a template. We can create, configure and delete AWS components and also reference them with each other.
The format is
CloudFormation supports most AWS services and the full list can be found here
Let's talk about AWS CloudFormation parameters
We can use referencing for using params anywhere within the template
The API name is
Fn:Ref and in the yaml config it is shortened to
We can also use pseudo params for AWS related values that we do not want to store in our code and again use them at any time. These can be like the AWS account id with
AWS::AccountId, the region with
AWS::Region and more.
We also have mappings which are fixed variables useful when adding sets of hardcoded data in our code. An example is
FN:FindInMap which allows us to search within maps.
Then we have outputs which are optional but work really well when we want to use the value of a service that was just created in order to reference it to another resource.
Then we have the cross stack reference where we create another template that uses a security group. We can reference that with
Fn::ImportValue. Once a stack is referenced in another template, all the references need to be deleted first before deleting the first stack.
We can control the creation of resources based on conditions. Such conditions are environment stage, AWS region etc
We have intrinsic function like and
Let's talk about AWS CloudFormation rollbacks
What is AWS CloudFront? It is a CDN (Content Delivery Network) formed of distributions and is mainly used to improve site’s performance as content is cached on multiple edge locations around the world.It provides DDOS protection and integrates with AWS firewall Shield
CloudFront can provide origins from:
Overall, clients send requests to any of the multiple edges around the world where the requests get forwarded to the origin along with any query params and headers. Then the origin responds with the available assets which then get cached in the edge location for future requests.
Both CloudFormation and CloudFront are services that I have not used much in the past but I understand their importance in our AWS stack. CloudFormation is definitely a service that requires a deeper dive with some coding examples (maybe a future blog post) to really understand its value.
Next week we're finally going to talk about the most interesting service in AWS for being a developer. Shall I ruin the surprise? Whatever. Next week will be about AWS Lambda!