eazevedo

cloudformation.template

Oct 1st, 2014
832
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {
  2.   "AWSTemplateFormatVersion" : "2010-09-09",
  3.  
  4.   "Description" : "CF bootstrapping template sample: windows instance running a powershell script, obtained from S3, note how cfn:init defines command to use option switch to run powershell",
  5.  
  6.   "Parameters" : {
  7.     "KeyPairName" : {
  8.       "Description" : "Name of an existing Amazon EC2 key pair",
  9.       "Type" : "String",
  10.    "Default" : "xxx"
  11.     },
  12.  
  13.  "WindowInstanceSubnet" : {
  14.       "Description" : "Subnet ID to launch instance",
  15.       "Type" : "String",
  16.       "Default" : "subnet-xxx"
  17.     },
  18.  
  19.     "WindowInstanceSGs": {
  20.     "Description": "Comma-delimited list of Security Group IDs for instance",
  21.     "Type": "CommaDelimitedList",
  22.       "Default": "sg-xxx, sg-xxx"
  23.     },
  24.  
  25.     "InstanceType" : {
  26.       "Description" : "Amazon EC2 instance type",
  27.       "Type" : "String",
  28.       "Default" : "t1.micro",
  29.       "AllowedValues" : [ "t1.micro", "m1.small", "m1.medium", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge"]
  30.     }
  31.   },
  32.  
  33.   "Mappings" : {
  34.     "AWSInstanceType2Arch" : {
  35.       "t1.micro"   : { "Arch" : "64" },
  36.       "m1.small"   : { "Arch" : "64" },
  37.       "m1.medium"  : { "Arch" : "64" },
  38.       "m1.large"   : { "Arch" : "64" },
  39.       "m1.xlarge"  : { "Arch" : "64" },
  40.       "m2.xlarge"  : { "Arch" : "64" },
  41.       "m2.2xlarge" : { "Arch" : "64" },
  42.       "m2.4xlarge" : { "Arch" : "64" },
  43.       "c1.medium"  : { "Arch" : "64" },
  44.       "c1.xlarge"  : { "Arch" : "64" }
  45.     },
  46.     "AWSRegionArch2AMI" : {
  47.       "us-east-1"      : {"64" : "ami-904be6f8"},
  48.       "us-west-2"      : {"64" : "ami-d38dcce3"},
  49.       "us-west-1"      : {"64" : "ami-5eb7961b"},
  50.       "eu-west-1"      : {"64" : "ami-06278771"},
  51.       "ap-southeast-1" : {"64" : "ami-b8f8bbea"},
  52.       "ap-southeast-2" : {"64" : "ami-a740d79d"},
  53.       "ap-northeast-1" : {"64" : "ami-2210a823"},
  54.       "sa-east-1"      : {"64" : "ami-9fc41c82"}
  55.     }
  56.   },
  57.  
  58.   "Resources" : {
  59.  
  60.     "InstanceRole":{
  61.       "Type":"AWS::IAM::Role",
  62.         "Properties" : {
  63.           "AssumeRolePolicyDocument" : {
  64.             "Statement": [{
  65.               "Effect" : "Allow",
  66.               "Principal" : {
  67.                 "Service" : [ "ec2.amazonaws.com" ]
  68.               },
  69.               "Action" : [ "sts:AssumeRole" ]
  70.             }]
  71.           },
  72.           "Path" : "/"
  73.         }
  74.     },
  75.      
  76.     "RolePolicies" : {
  77.       "Type" : "AWS::IAM::Policy",
  78.       "Properties" : {
  79.         "PolicyName" : "VPCupdate",
  80.         "PolicyDocument" : {
  81.           "Statement" : [
  82.    {
  83.             "Action" : "*",
  84.             "Effect" : "Allow",
  85.             "Resource" : "*"
  86.    },
  87.    {
  88.             "Action" : "*",
  89.             "Effect" : "Allow",
  90.             "Resource" : "*"
  91.    }
  92.     ]
  93.         },
  94.         "Roles" : [ { "Ref" : "InstanceRole" } ]
  95.       }
  96.     },
  97.      
  98.     "InstanceProfile" : {
  99.       "Type":"AWS::IAM::InstanceProfile",
  100.       "Properties" : {
  101.         "Path" : "/",
  102.         "Roles" : [ { "Ref":"InstanceRole" } ]
  103.       }
  104.     },
  105.  
  106.   "WindowInstance": {
  107.       "Type" : "AWS::EC2::Instance",
  108.       "Metadata" : {
  109.         "AWS::CloudFormation::Init" : {
  110.           "config" : {
  111.             "files" : {
  112.               "C:\\cfn\\iis.ps1" : {
  113.                 "source" : "https://s3-eu-west-1.amazonaws.com/scripscf/iis.ps1"
  114.               }
  115.             },
  116.             "commands" : {
  117.         "1-update" : {
  118.          "command" : "powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File C:\\cfn\\iis.ps1"
  119.               }
  120.             }
  121.            
  122.           }
  123.         }
  124.       },
  125.       "Properties": {
  126.         "InstanceType" : { "Ref" : "InstanceType" },
  127.         "ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" },
  128.                       { "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
  129.          "Tags":[
  130.             {
  131.                   "Key":"Name",
  132.                   "Value":"WindowInstance"
  133.             }
  134.         ],
  135.   "IamInstanceProfile" : { "Ref" : "InstanceProfile" },
  136.         "SubnetId" : { "Ref" : "WindowInstanceSubnet" },
  137.         "SecurityGroupIds" : { "Ref" : "WindowInstanceSGs" },
  138.         "KeyName" : { "Ref" : "KeyPairName" },
  139.         "UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
  140.                 ""
  141.           ]]}}
  142.         }
  143.     },
  144.  
  145.     "WindowInstanceWaitHandle" : {
  146.       "Type" : "AWS::CloudFormation::WaitConditionHandle"
  147.     },
  148.  
  149.     "WindowInstanceWaitCondition" : {
  150.       "Type" : "AWS::CloudFormation::WaitCondition",
  151.       "DependsOn" : "WindowInstance",
  152.       "Properties" : {
  153.         "Handle" : {"Ref" : "WindowInstanceWaitHandle"},
  154.         "Timeout" : "1500"
  155.       }
  156.     }
  157.   },
  158.  
  159.   "Outputs" : {
  160.   }
  161. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×