Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "AWSTemplateFormatVersion" : "2010-09-09",
- "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",
- "Parameters" : {
- "KeyPairName" : {
- "Description" : "Name of an existing Amazon EC2 key pair",
- "Type" : "String",
- "Default" : "xxx"
- },
- "WindowInstanceSubnet" : {
- "Description" : "Subnet ID to launch instance",
- "Type" : "String",
- "Default" : "subnet-xxx"
- },
- "WindowInstanceSGs": {
- "Description": "Comma-delimited list of Security Group IDs for instance",
- "Type": "CommaDelimitedList",
- "Default": "sg-xxx, sg-xxx"
- },
- "InstanceType" : {
- "Description" : "Amazon EC2 instance type",
- "Type" : "String",
- "Default" : "t1.micro",
- "AllowedValues" : [ "t1.micro", "m1.small", "m1.medium", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge"]
- }
- },
- "Mappings" : {
- "AWSInstanceType2Arch" : {
- "t1.micro" : { "Arch" : "64" },
- "m1.small" : { "Arch" : "64" },
- "m1.medium" : { "Arch" : "64" },
- "m1.large" : { "Arch" : "64" },
- "m1.xlarge" : { "Arch" : "64" },
- "m2.xlarge" : { "Arch" : "64" },
- "m2.2xlarge" : { "Arch" : "64" },
- "m2.4xlarge" : { "Arch" : "64" },
- "c1.medium" : { "Arch" : "64" },
- "c1.xlarge" : { "Arch" : "64" }
- },
- "AWSRegionArch2AMI" : {
- "us-east-1" : {"64" : "ami-904be6f8"},
- "us-west-2" : {"64" : "ami-d38dcce3"},
- "us-west-1" : {"64" : "ami-5eb7961b"},
- "eu-west-1" : {"64" : "ami-06278771"},
- "ap-southeast-1" : {"64" : "ami-b8f8bbea"},
- "ap-southeast-2" : {"64" : "ami-a740d79d"},
- "ap-northeast-1" : {"64" : "ami-2210a823"},
- "sa-east-1" : {"64" : "ami-9fc41c82"}
- }
- },
- "Resources" : {
- "InstanceRole":{
- "Type":"AWS::IAM::Role",
- "Properties" : {
- "AssumeRolePolicyDocument" : {
- "Statement": [{
- "Effect" : "Allow",
- "Principal" : {
- "Service" : [ "ec2.amazonaws.com" ]
- },
- "Action" : [ "sts:AssumeRole" ]
- }]
- },
- "Path" : "/"
- }
- },
- "RolePolicies" : {
- "Type" : "AWS::IAM::Policy",
- "Properties" : {
- "PolicyName" : "VPCupdate",
- "PolicyDocument" : {
- "Statement" : [
- {
- "Action" : "*",
- "Effect" : "Allow",
- "Resource" : "*"
- },
- {
- "Action" : "*",
- "Effect" : "Allow",
- "Resource" : "*"
- }
- ]
- },
- "Roles" : [ { "Ref" : "InstanceRole" } ]
- }
- },
- "InstanceProfile" : {
- "Type":"AWS::IAM::InstanceProfile",
- "Properties" : {
- "Path" : "/",
- "Roles" : [ { "Ref":"InstanceRole" } ]
- }
- },
- "WindowInstance": {
- "Type" : "AWS::EC2::Instance",
- "Metadata" : {
- "AWS::CloudFormation::Init" : {
- "config" : {
- "files" : {
- "C:\\cfn\\iis.ps1" : {
- "source" : "https://s3-eu-west-1.amazonaws.com/scripscf/iis.ps1"
- }
- },
- "commands" : {
- "1-update" : {
- "command" : "powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File C:\\cfn\\iis.ps1"
- }
- }
- }
- }
- },
- "Properties": {
- "InstanceType" : { "Ref" : "InstanceType" },
- "ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" },
- { "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
- "Tags":[
- {
- "Key":"Name",
- "Value":"WindowInstance"
- }
- ],
- "IamInstanceProfile" : { "Ref" : "InstanceProfile" },
- "SubnetId" : { "Ref" : "WindowInstanceSubnet" },
- "SecurityGroupIds" : { "Ref" : "WindowInstanceSGs" },
- "KeyName" : { "Ref" : "KeyPairName" },
- "UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
- ""
- ]]}}
- }
- },
- "WindowInstanceWaitHandle" : {
- "Type" : "AWS::CloudFormation::WaitConditionHandle"
- },
- "WindowInstanceWaitCondition" : {
- "Type" : "AWS::CloudFormation::WaitCondition",
- "DependsOn" : "WindowInstance",
- "Properties" : {
- "Handle" : {"Ref" : "WindowInstanceWaitHandle"},
- "Timeout" : "1500"
- }
- }
- },
- "Outputs" : {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement