Advertisement
uopspop

Untitled

Sep 12th, 2019
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.87 KB | None | 0 0
  1. {
  2. "AWSTemplateFormatVersion" : "2010-09-09",
  3.  
  4. "Description" : "AWS CloudFormation Cross-Stack Reference Sample Template: Demonstrates how to reference resources from a different stack. This template provisions an EC2 instance in an EC2 Security Group provisioned in a different stack. **WARNING** This template creates an Amazon EC2 instance. You will be billed for the AWS resources used if you create a stack from this template.",
  5.  
  6. "Parameters": {
  7. "NetworkStackName": {
  8. "Description": "Name of an active CloudFormation stack that contains the networking resources, such as the subnet and security group, that will be used in this stack.",
  9. "Type": "String",
  10. "MinLength" : 1,
  11. "MaxLength" : 255,
  12. "AllowedPattern" : "^[a-zA-Z][-a-zA-Z0-9]*$",
  13. "Default" : "SampleNetworkCrossStack"
  14. }
  15. },
  16.  
  17. "Mappings" : {
  18. "AWSRegionArch2AMI" : {
  19. "us-east-1" : {"PV64" : "ami-8ff710e2", "HVM64" : "ami-f5f41398", "HVMG2" : "ami-4afd1d27"},
  20. "us-west-2" : {"PV64" : "ami-eff1028f", "HVM64" : "ami-d0f506b0", "HVMG2" : "ami-ee897b8e"},
  21. "us-west-1" : {"PV64" : "ami-ac85fbcc", "HVM64" : "ami-6e84fa0e", "HVMG2" : "ami-69106909"},
  22. "eu-west-1" : {"PV64" : "ami-23ab2250", "HVM64" : "ami-b0ac25c3", "HVMG2" : "ami-936de5e0"},
  23. "eu-central-1" : {"PV64" : "ami-27c12348", "HVM64" : "ami-d3c022bc", "HVMG2" : "ami-8e7092e1"},
  24. "ap-northeast-1" : {"PV64" : "ami-26160d48", "HVM64" : "ami-29160d47", "HVMG2" : "ami-91809aff"},
  25. "ap-northeast-2" : {"PV64" : "NOT_SUPPORTED", "HVM64" : "ami-cf32faa1", "HVMG2" : "NOT_SUPPORTED"},
  26. "ap-southeast-1" : {"PV64" : "ami-f3dd0a90", "HVM64" : "ami-1ddc0b7e", "HVMG2" : "ami-3c30e75f"},
  27. "ap-southeast-2" : {"PV64" : "ami-8f94b9ec", "HVM64" : "ami-0c95b86f", "HVMG2" : "ami-543d1137"},
  28. "sa-east-1" : {"PV64" : "ami-e188018d", "HVM64" : "ami-fb890097", "HVMG2" : "NOT_SUPPORTED"},
  29. "cn-north-1" : {"PV64" : "ami-77a46e1a", "HVM64" : "ami-05a66c68", "HVMG2" : "NOT_SUPPORTED"}
  30. }
  31. },
  32.  
  33. "Resources" : {
  34. "WebServerInstance": {
  35. "Type": "AWS::EC2::Instance",
  36. "Metadata" : {
  37. "AWS::CloudFormation::Init" : {
  38. "configSets" : {
  39. "All" : [ "ConfigureSampleApp" ]
  40. },
  41.  
  42. "ConfigureSampleApp" : {
  43. "packages" : {
  44. "yum" : {
  45. "httpd" : []
  46. }
  47. },
  48.  
  49. "files" : {
  50. "/var/www/html/index.html" : {
  51. "content" : { "Fn::Join" : ["\n", [
  52. "<img src=\"https://s3.amazonaws.com/cloudformation-examples/cloudformation_graphic.png\" alt=\"AWS CloudFormation Logo\"/>",
  53. "<h1>Congratulations, you have successfully launched the AWS CloudFormation sample.</h1>"
  54. ]]},
  55. "mode" : "000644",
  56. "owner" : "root",
  57. "group" : "root"
  58. }
  59. },
  60.  
  61. "services" : {
  62. "sysvinit" : {
  63. "httpd" : { "enabled" : "true", "ensureRunning" : "true" }
  64. }
  65. }
  66. }
  67. }
  68. },
  69. "Properties": {
  70. "InstanceType" : "t2.micro",
  71. "ImageId": { "Fn::FindInMap": [ "AWSRegionArch2AMI", { "Ref": "AWS::Region" } , "HVM64" ] },
  72. "NetworkInterfaces" : [{
  73. "GroupSet" : [{ "Fn::ImportValue" : {"Fn::Sub": "${NetworkStackName}-SecurityGroupID" } }],
  74. "AssociatePublicIpAddress" : "true",
  75. "DeviceIndex" : "0",
  76. "DeleteOnTermination" : "true",
  77. "SubnetId" : { "Fn::ImportValue" : {"Fn::Sub": "${NetworkStackName}-SubnetID" } }
  78. }],
  79. "UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
  80. "#!/bin/bash -xe\n",
  81. "yum update -y aws-cfn-bootstrap\n",
  82.  
  83. "# Install the files and packages from the metadata\n",
  84. "/opt/aws/bin/cfn-init -v ",
  85. " --stack ", { "Ref" : "AWS::StackName" },
  86. " --resource WebServerInstance ",
  87. " --configsets All ",
  88. " --region ", { "Ref" : "AWS::Region" }, "\n",
  89.  
  90. "# Signal the status from cfn-init\n",
  91. "/opt/aws/bin/cfn-signal -e $? ",
  92. " --stack ", { "Ref" : "AWS::StackName" },
  93. " --resource WebServerInstance ",
  94. " --region ", { "Ref" : "AWS::Region" }, "\n"
  95. ]]}}
  96. },
  97. "CreationPolicy" : {
  98. "ResourceSignal" : {
  99. "Timeout" : "PT5M"
  100. }
  101. }
  102. }
  103. },
  104.  
  105. "Outputs" : {
  106. "URL" : {
  107. "Description" : "URL of the sample website",
  108. "Value" : { "Fn::Join" : [ "", [ "http://", { "Fn::GetAtt" : [ "WebServerInstance", "PublicDnsName" ]}]]}
  109. }
  110. }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement