{"id":1123,"date":"2018-02-20T02:31:34","date_gmt":"2018-02-20T02:31:34","guid":{"rendered":"http:\/\/wiki.thomasandsofia.com\/?p=1123"},"modified":"2018-02-21T11:40:40","modified_gmt":"2018-02-21T11:40:40","slug":"cloudformation-outputs","status":"publish","type":"post","link":"https:\/\/wiki.thomasandsofia.com\/?p=1123","title":{"rendered":"CloudFormation Outputs"},"content":{"rendered":"<p><a href=\"https:\/\/www.udemy.com\/aws-cloudformation-master-class\/learn\/v4\/t\/lecture\/8162150?start=0\" target=\"_blank\" rel=\"noopener\">https:\/\/www.udemy.com\/aws-cloudformation-master-class\/learn\/v4\/t\/lecture\/8162150?start=0<\/a><\/p>\n<p><a href=\"http:\/\/wiki.thomasandsofia.com\/2018\/02\/18\/cloud-formation-main-menu\/\" target=\"_blank\" rel=\"noopener\">Course Main Menu<\/a><\/p>\n<h2>Section 6 Main Menu<\/h2>\n<ul>\n<li><a href=\"#Overview\">Overview<\/a><\/li>\n<li><a href=\"#Hands\">Create Security Group with Outputs Hands On<\/a><\/li>\n<li><a href=\"#open\">Cross Stack Reference Hands On<\/a><\/li>\n<li><a href=\"#quiz\">Quiz<\/a><\/li>\n<\/ul>\n<p><a name=\"Overview\"><\/a><\/p>\n<h2>Overview<\/h2>\n<p>What are outputs<\/p>\n<ul>\n<li>Outputs are optional outputs values that we can import into other stacks.<\/li>\n<li>You can also view the outputs in the AWS Console or by using the AWS CLI\n<ul>\n<li>If you want to view a return value<\/li>\n<\/ul>\n<\/li>\n<li>Usage Examples:\n<ul>\n<li>To get the VPC ID and Subnet IDs if you define a network CloudFormation.<\/li>\n<li>To collaborate on a stack with someone else.\u00a0 You can use their outputs for your part of the stack.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><a name=\"Hands\"><\/a><\/p>\n<h2>Create Security Group with Outputs Hands On<\/h2>\n<p><a href=\"https:\/\/www.udemy.com\/aws-cloudformation-master-class\/learn\/v4\/t\/lecture\/8162152?start=0\" target=\"_blank\" rel=\"noopener\">https:\/\/www.udemy.com\/aws-cloudformation-master-class\/learn\/v4\/t\/lecture\/8162152?start=0<\/a><\/p>\n<p>First we will create a Security Group with specific rules that will output<\/p>\n<ul>\n<li>Create and SSH Security Group<\/li>\n<li>Important!\n<ul>\n<li>The Export Name must be globally unique!<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<pre>Outputs:\r\n   Logical ID:\r\n      Description: Information about the value\r\n      Value: Value to return\r\n      Export:\r\n         Name: Value to export\r\n<\/pre>\n<pre>Resources:\r\n  # here we define a SSH security group that will be used in the entire company\r\n  MyCompanyWideSSHSecurityGroup:\r\n    # http:\/\/docs.aws.amazon.com\/AWSCloudFormation\/latest\/UserGuide\/aws-properties-ec2-security-group.html\r\n    Type: AWS::EC2::SecurityGroup\r\n    Properties:\r\n      GroupDescription: Enable SSH access via port 22\r\n      SecurityGroupIngress:\r\n        # we have a lot of rules because it's a perfect security group\r\n        # finance team network\r\n      - CidrIp: 10.0.48.0\/24\r\n        FromPort: 22\r\n        IpProtocol: tcp\r\n        ToPort: 22\r\n        # marketing team network\r\n      - CidrIp: 10.0.112.0\/24\r\n        FromPort: 22\r\n        IpProtocol: tcp\r\n        ToPort: 22\r\n        # application team support network\r\n      - CidrIp: 10.0.176.0\/24\r\n        FromPort: 22\r\n        IpProtocol: tcp\r\n        ToPort: 22\r\n\r\nOutputs:\r\n  StackSSHSecurityGroup:\r\n    Description: The SSH Security Group for our Company\r\n    Value: !Ref MyCompanyWideSSHSecurityGroup\r\n    Export:\r\n      Name: SSHSecurityGroup\r\n<\/pre>\n<p>As entered into AWS:<\/p>\n<ul>\n<li>Stack Name: My-SG-Stack\n<ul>\n<li>All Defaults &gt; Create<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><a href=\"http:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2018\/02\/cf-sg1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1133\" src=\"http:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2018\/02\/cf-sg1.png\" alt=\"\" width=\"1083\" height=\"443\" srcset=\"https:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2018\/02\/cf-sg1.png 1083w, https:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2018\/02\/cf-sg1-300x123.png 300w, https:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2018\/02\/cf-sg1-768x314.png 768w, https:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2018\/02\/cf-sg1-1024x419.png 1024w, https:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2018\/02\/cf-sg1-150x61.png 150w\" sizes=\"auto, (max-width: 1083px) 100vw, 1083px\" \/><\/a><\/p>\n<ul>\n<li>From CloudFormation<\/li>\n<\/ul>\n<p><a href=\"http:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2018\/02\/cf-sg2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1134\" src=\"http:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2018\/02\/cf-sg2.png\" alt=\"\" width=\"1249\" height=\"346\" srcset=\"https:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2018\/02\/cf-sg2.png 1249w, https:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2018\/02\/cf-sg2-300x83.png 300w, https:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2018\/02\/cf-sg2-768x213.png 768w, https:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2018\/02\/cf-sg2-1024x284.png 1024w, https:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2018\/02\/cf-sg2-150x42.png 150w\" sizes=\"auto, (max-width: 1249px) 100vw, 1249px\" \/><\/a><\/p>\n<p><a name=\"open\"><\/a><\/p>\n<h2>Cross Stack Reference Hands On<\/h2>\n<p><a href=\"https:\/\/www.udemy.com\/aws-cloudformation-master-class\/learn\/v4\/t\/lecture\/8162154?start=0\" target=\"_blank\" rel=\"noopener\">https:\/\/www.udemy.com\/aws-cloudformation-master-class\/learn\/v4\/t\/lecture\/8162154?start=0<\/a><\/p>\n<p>Now we&#8217;ll use the data output from the first Hands On into a new CF template.<\/p>\n<ul>\n<li>Create a second template that leverages that security group\n<ul>\n<li>Fn::ImportValue<\/li>\n<\/ul>\n<\/li>\n<li>Important!\n<ul>\n<li>You cannot delete the underlying stack until all references are deleted too!<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre>Resources:\r\n  MySecureInstance:\r\n    # http:\/\/docs.aws.amazon.com\/AWSCloudFormation\/latest\/UserGuide\/aws-properties-ec2-instance.html\r\n    Type: AWS::EC2::Instance\r\n    Properties:\r\n      AvailabilityZone: us-east-1a\r\n      ImageId: ami-a4c7edb2\r\n      InstanceType: t2.micro\r\n      SecurityGroups:\r\n        # we reference the output here, using the Fn::ImportValue function\r\n        - !ImportValue SSHSecurityGroup\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><a name=\"Quiz\"><\/a><\/p>\n<h2>Quiz<\/h2>\n<h4>Outputs are<\/h4>\n<ul>\n<li>Mandatory<\/li>\n<li><strong>Optional<\/strong><\/li>\n<\/ul>\n<h4>Any Outputs can be referenced crossed stack<\/h4>\n<ul>\n<li>Yes<\/li>\n<li><strong>No<\/strong><\/li>\n<\/ul>\n<p>You need to export the output value before being able to use it in another stack<\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/www.udemy.com\/aws-cloudformation-master-class\/learn\/v4\/t\/lecture\/8162150?start=0 Course Main Menu Section 6 Main Menu Overview Create Security Group with Outputs Hands On Cross Stack Reference Hands On Quiz Overview What are outputs Outputs are optional outputs values that we can import into other stacks. You can also view the outputs in the AWS Console or by using the AWS CLI If ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/wiki.thomasandsofia.com\/?p=1123\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-1123","post","type-post","status-publish","format-standard","hentry","category-cloudformation"],"_links":{"self":[{"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/posts\/1123","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1123"}],"version-history":[{"count":17,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/posts\/1123\/revisions"}],"predecessor-version":[{"id":1154,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/posts\/1123\/revisions\/1154"}],"wp:attachment":[{"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}