J Cole Morrison
J Cole Morrison

J Cole Morrison

DevOps Specialist, Software Engineer, former Techstars Hackstar, and Founder / Instructor at AwsDevops.io!



Complete Guides:

CloudFormation Complete Guide

The Complete CloudFormation Guide: Outputs

Posted by J Cole Morrison on .

The Complete CloudFormation Guide: Outputs

Posted by J Cole Morrison on .

The Complete CloudFormation Guide Outputs

Table of Contents

  1. Introduction
  2. What Are We Doing?
  3. The Video: Outputs
  4. The Template So Far: Final Version
  5. Next Steps
  6. The Complete CloudFormation Guide Index

Introduction

We are now on our last piece of template anatomy: Outputs. When used on its own, all Outputs do is show up in the console but in this video we'll see how they're used for cross-stack references, so how you can use resources from one template in another one. With this, we will have covered all of our top nine properties of AWS CloudFormation template anatomy!

In the next and final series post, we will relaunch our template with all of the new awesome changes we've made throughout the series thus far and we'll discuss what the next best steps are for your learning journey.

What Are We Doing?

In this video, we'll create an Outputs section at the end of our AWS CloudFormation template to round out the series. We'll set it up with a logical ID, description, and value, as well as discuss what this value can be. Also we'll bring in some old friends (pseudo parameters and intrinsic functions) to round it out. Then we're done!

The Video: Outputs

The Template So Far: Final Version

{
  "AWSTemplateFormatVersion" : "2010-09-09",
  "Description": "A CFN template for learning",
  "Metadata": {
    "Author": { "Ref": "ParamAuthorName" }
  },
  "Parameters": {
    "ParamAuthorName": {
      "Type": "String",
      "Description": "Owner of the CFN Template."
    },
    "ParamAllowSSHFromRange": {
      "Type": "String",
      "Description": "IP CidrBlock to allow SSH access. i.e. 100.100.100.100/32",
      "Default": "0.0.0.0/0"
    },
    "ParamAllowSSHAccess": {
      "Type": "String",
      "Default": "true",
      "AllowedValues": ["true", "false"],
      "ConstraintDescription":"Whether to allow SSH access into the EC2 server"
    }
  },
  "Conditions": {
    "AllowSSHAccess": {
      "Fn::Equals": [{ "Ref": "ParamAllowSSHAccess" }, "true"]
    }
  },
  "Resources": {
    "SecurityGroup": {
      "Type": "AWS::EC2::SecurityGroup",
      "Properties": {
        "GroupDescription": "Security group for SSH and HTTP access",
        "SecurityGroupIngress": [
          {
            "IpProtocol":"tcp",
            "FromPort":"80",
            "ToPort":"80",
            "CidrIp": "0.0.0.0/0"
          },
          {
            "Fn::If": [
              "AllowSSHAccess",
              {
                "IpProtocol":"tcp",
                "FromPort":"22",
                "ToPort":"22",
                "CidrIp": { "Ref": "ParamAllowSSHFromRange" }
              },
              {
                "Ref": "AWS::NoValue"
              }
            ]
          }
        ]
      }
    }
  },
  "Outputs": {
    "SecurityGroupName": {
      "Description": "Name of Instance Security Group",
      "Value": {
        "Ref": "SecurityGroup"
      }
    },
    "SecurityGroupId": {
      "Description": "ID of Instance Security Group",
      "Value": {
        "Fn::GetAtt": [
          "SecurityGroup",
          "GroupId"
        ]
      },
      "Export": {
        "Name": {
          "Fn::Sub": "${AWS::StackName}-SecurityGroupId"
        }
      }
    }
  }
}

Next Steps

The Next Post - Relaunch!

The Previous Post - Transforms

The Complete CloudFormation Guide Index

If you're enjoying this series and finding it useful, be sure to check out the rest of the blog posts in it! The links below will take you to the other posts in The Complete CloudFormation Guide here on Tech Guides and Thoughts so you can continue building your CloudFormation template along with me.

  1. The Complete CloudFormation Guide
  2. An Introduction to and History of CloudFormation
  3. The Main Concepts of CloudFormation
  4. How CloudFormation Does Updates and Deletes
  5. Our Project Setup
  6. Resources
  7. Parameters and Refs
  8. Our First Time Launch
  9. Functions, Pseudo Parameters, and Conditions Part 1
  10. Functions, Pseudo Parameters, and Conditions Part 2
  11. Mappings
  12. Transforms
  13. Outputs
  14. Relaunch!
  15. The Best Next Steps to Take from Here

Enjoy Posts Like These? Sign up to my mailing list!

My Tech Guides and Thoughts Mailing List

J Cole Morrison

J Cole Morrison

http://start.jcolemorrison.com

DevOps Specialist, Software Engineer, former Techstars Hackstar, and Founder / Instructor at AwsDevops.io!

View Comments...
J Cole Morrison

J Cole Morrison

DevOps Specialist, Software Engineer, former Techstars Hackstar, and Founder / Instructor at AwsDevops.io!



Complete Guides: