May 21, 2023

Cloud Formation

 Aws cloud services + provisioning of aws cloud resource 

(EC2, lambda, load balancer) 



Use case

  • Hard to manage infrastructure


  • Complex and time consuming to replace infra in another region / account 


  • Incremental upgrades become critical 



Cloud formation template: 

1. Act as a blueprint for the provisioning of resource

2. Created in JSON or YAML file




Stacksets:

It extends the functionality of stacks which enables you to create, update or delete stacks across multiple accounts and regions with single operations.




Create Template file : 

Allowed templates : JSON | YAML

Definition file of all the resources you will be using for cloud formation 


Stack 

Define initial template file that you are going to deploy to this stack


Changeset : 

Upload modified file into cloud formation and before applying this change set to the stack 

Generate the preview of changes to the existing stack. 


AwsTemplateFormatversion


AwsTemplateFormatversion: “2010-09-09”

This is the only allowed value for this property.


If you don't define this property in the YAML template then by default the YAML file will refer “2010-09-09” as a default value. 



Resources:

  S3Bucket:

    Type: 'AWS::S3::Bucket'

    DeletionPolicy: Retain

    Properties:

      BucketName: DOC-EXAMPLE-BUCKET

  S3Bucket2:

    Type: 'AWS::S3::Bucket'

    DeletionPolicy: Retain

    Properties:

      BucketName: DOC-EXAMPLE-BUCKET2




Infrastructure as a code for the 


Aws cloud formation is a free aws service.


CREATE UPDATE DELETE


Cloud formation enables you to 

1. Model and setup your infra using templates

2. Automate provisioning and configuration

3. Manage dependencies

4. Easily control track change of infra 

5. Rollback or delete clearly 



Update stack

Stacks:

- When cloud formation executes a template it creates a stack

- to update the resources within a template you need to update the stack 

- a set of related resources as a single unit is called stack 




Change Set

- Before updating a stack you can generate change set 

- a change set allow you to see how the changes will impact to your running resources

- this is very important for live system, this can delete the existing resource and create new one


Ex RDS name change - existing RDS will be deleted - Potential data loss 

Change sets provide visibility on actions to be taken using new template


Template anatomy

 

  Resources:

    LOGICAL ID:

      TYPE OF RESOURCE :

        PROPERTIES:

          —----

          —----

          —----

No comments:

Post a Comment