concept template in category aws

appears as: templates, template, templates, Template, The template, A template
AWS CloudFormation in Action MEAP V02

This is an excerpt from Manning's book AWS CloudFormation in Action MEAP V02.

Like other systems we’ve talked about in this section, Puppet has a master and an agent. The master is the system that manages the configuration information for all of the nodes that it controls. Puppet calls their equivalent of templates (files containing the code that defines how a system will be configured), manifests.

Figure 2.1 The workflow from composing the template through deploying the stack

CloudFormation helps you manage change. We’ll talk about this at length in chapter 5, but because it is a declarative model, when you manage change using CloudFormation, it keeps track of which resources are deployed, and compares the changes in the template to those that are running and handles the update optimally. For example, if your template is written in such a way that you always want to have the latest version of Apache updated when you push changes, it can track that and will perform the update. Conversely, you can specify a parameter with the exact version that you want and if it already installed, it will not be updated. You can rollback changes easily. You can manage your changes just like you do your code in a version control system.

The syntax is the same, which is convenient, because you can easily make sure the template is “well formed” and it isn’t a missing bracket or quote that prevents CloudFormation from using it. However, there are some critical differences in how CloudFormation operates with on JSON, versus using it for API payloads and other data transmission uses.

A description at the top of the template is often used for documentation. For example, a simple description of what the template does. This entered as a key value pair:

"Description" : "This is my template.",

This description will appear in the CloudFormation console when you are uploading the template. You will also, see it when you are examining a stack that is running in production.  This great place to incorporate an overview of the stacks purpose into the stack so it will be seen by your colleagues. The character limit for the Description is 4096 characters.

Amazon Web Services in Action, Second Edition

This is an excerpt from Manning's book Amazon Web Services in Action, Second Edition.

Choose Specify an Amazon S3 template URL and enter https://s3.amazonaws.com/awsinaction-code2/chapter02/template.yaml to use the template prepared for this chapter. Proceed with the next step of the wizard.

We use the term blueprint when discussing infrastructure automation in general. Blueprints used for AWS CloudFormation, a configuration management service, are called templates.

A template is a description of your infrastructure, written in JSON or YAML, that can be interpreted by CloudFormation. The idea of describing something rather than listing the necessary actions is called a declarative approach. Declarative means you tell CloudFormation how your infrastructure should look. You aren’t telling CloudFormation what actions are needed to create that infrastructure, and you don’t specify the sequence in which the actions need to be executed.

  • Use a text editor or IDE to write a template from scratch.
  • A declarative approach like that used by CloudFormation is simpler: just change the InstanceType property and update the template. InstanceType can be passed to the template via a parameter. That’s it! You can begin creating the template.

    Listing 4.12. Template to create an EC2 instance with CloudFormation
    ---
    AWSTemplateFormatVersion: '2010-09-09'
    Description: 'AWS in Action: chapter 4'
    Parameters:
      KeyName:                                                    #1
        Description: 'Key Pair name'
        Type: 'AWS::EC2::KeyPair::KeyName'
        Default: mykey
      VPC:                                                        #2
        # [...]
      Subnet:                                                     #2
        # [...]
      InstanceType:                                               #3
        Description: 'Select one of the possible instance types'
        Type: String
        Default: 't2.micro'
        AllowedValues": ['t2.micro', 't2.small', 't2.medium']
    Resources:
      SecurityGroup:                                              #4
        Type: 'AWS::EC2::SecurityGroup'
        Properties:
          # [...]
      VM:                                                         #5
        Type: 'AWS::EC2::Instance'
        Properties:
          ImageId: 'ami-6057e21a'
          InstanceType: !Ref InstanceType
          KeyName: !Ref KeyName
          NetworkInterfaces:
           - AssociatePublicIpAddress: true
             DeleteOnTermination: true
             DeviceIndex: 0
             GroupSet:
             - !Ref SecurityGroup
             SubnetId: !Ref Subnet
    Outputs:
      PublicName:                                                 #6
        Value: !GetAtt 'Server.PublicDnsName'
        Description: 'Public name (connect via SSH as user ec2-user)'
    

    You can find the full code for the template at /chapter04/virtualmachine.yaml in the book’s code folder. Please don’t worry about VPC, subnets, and security groups at the moment; you’ll get to know them in chapter 6.

    Figure 4.14. Creating a CloudFormation stack: selecting a template (step 1 of 4)
    sitemap

    Unable to load book!

    The book could not be loaded.

    (try again in a couple of minutes)

    manning.com homepage
    test yourself with a liveTest