CLOUDFORMATION TEMPLATES

CFT is a service that helps you model and set up your Amazon Web Services resources

CFT using  two scripting langauges
1.yaml
2.json

CFT advatages
we can write/create resources or services in aws by using the cft.
Simplify infrastructure management.
Quickly replicate your infrastructure.
Easily control and track changes to your infrastructure.


Disadvantages
we cant write multiple templates for single resource.


Templates can include several major sections:
– AWSTemplateFormatVersion
– Description
– Metadata
– Parameters
– Mappings
– Conditions
– Resources
– Outputs



######TEMPLATE ARCHITECUTE######
{
"AWSTemplateFormatVersion" : "version date",
"Description" : "JSON string",


"Metadata" : {
template metadata
###EXAMPLE it reads cfn-init (template meta data)
cfn-init --stack|-s stack.name.or.id \
         --resource|-r logical.resource.id \
         --region region
         --access-key access.key \
         --secret-key secret.key \
         --role rolename\
         --credential-file|-f credential.file \
         --configsets|-c config.sets \
         --url|-u service.url \
         --http-proxy HTTP.proxy \
         --https-proxy HTTPS.proxy \
         --verbose|-v


####EXAMPLE cfn-interface using by groups and lables
############you could group all EC2-related parameters in one group and all VPC-related parameters in another group
"Metadata" : {
  "AWS::CloudFormation::Interface" : {
    "ParameterGroups" : [ ParameterGroup, ... ],
    "ParameterLabels" : ParameterLabel
  }
}


####WRITE A SIMPLE EC2 TEMPLATE####

{
    "AWSTemplateFormatVersion" : "2010-09-09",
   
    "Resources" : {
    "KIRANTESTINGEC2" : {
        "Type" : "AWS::EC2::Instance",
    "Properties" : {
    "ImageId" : "ami-0d9462a653c34dab7",
    "InstanceType" : "t2.micro"
    }
    }
    }
    }


#####WRITE A SAMPLE S3 TEMPLATE###
{
    "AWSTemplateFormatVersion" : "2010-09-09",
    "Resources" : {
    "S3TESTINGBUCKET" : {
    "Type" :  "AWS::S3::Bucket"
    }
    }
}

####WRITE A SAMPLE VPC TEMPLATE##
{
    "AWSTemplateFormatVersion" : "2010-09-09",
    "Resources" : {
    "VPCKIRANTESTING" : {
    "Type" :  "AWS::EC2::VPC",
    "Properties" : {
        "CidrBlock" : "10.0.0.0/16"
    }
    }
    }
}








No comments: