{
"AWSTemplateFormatVersion": "2010-09-09",
"Description" : "AWS CloudFormation Sample Template: Launches OpsWorks stack, layer, instances and associated resources to run a PHP application. ** This template creates one or more Amazon EC2 instances. You will be billed for the AWS resources used if you create a stack from this template.",
"Resources": {
"myStack": {
"Type": "AWS::OpsWorks::Stack",
"Properties": {
"Name": {
"Ref": "AWS::StackName"
},
"ServiceRoleArn": {
"Fn::GetAtt": [ "OpsWorksServiceRole", "Arn"]
},
"DefaultInstanceProfileArn": {
"Fn::GetAtt": [ "OpsWorksInstanceProfile", "Arn"]
}
}
},
"myLayer": {
"Type": "AWS::OpsWorks::Layer",
"DependsOn": "myApp",
"Properties": {
"StackId": {
"Ref": "myStack"
},
"Name": "MyPHPApp",
"Type": "php-app",
"Shortname": "php-app",
"EnableAutoHealing": "true",
"AutoAssignElasticIps": "false",
"AutoAssignPublicIps": "true"
}
},
"myInstance1": {
"Type": "AWS::OpsWorks::Instance",
"Properties": {
"StackId": {
"Ref": "myStack"
},
"LayerIds": [
{
"Ref": "myLayer"
}
],
"InstanceType": "m1.small"
}
},
"myInstance2": {
"Type": "AWS::OpsWorks::Instance",
"Properties": {
"StackId": {
"Ref": "myStack"
},
"LayerIds": [
{
"Ref": "myLayer"
}
],
"InstanceType": "m1.small"
}
},
"myApp": {
"Type": "AWS::OpsWorks::App",
"Properties": {
"StackId": {
"Ref": "myStack"
},
"Name": "MyPHPApp",
"Type": "php",
"AppSource": {
"Type": "git",
"Url": "git://github.com/amazonwebservices/opsworks-demo-php-simple-app.git",
"Revision": "version1"
},
"Attributes": {
"DocumentRoot": " "
}
}
},
"OpsWorksServiceRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": [
"opsworks.amazonaws.com"
]
},
"Action": [
"sts:AssumeRole"
]
}
]
},
"Path": "/",
"Policies": [
{
"PolicyName": "opsworks-service",
"PolicyDocument": {
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:*",
"iam:PassRole",
"cloudwatch:GetMetricStatistics",
"elasticloadbalancing:*"
],
"Resource": "*"
}
]
}
}
]
}
},
"OpsWorksInstanceRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": [
"ec2.amazonaws.com"
]
},
"Action": [
"sts:AssumeRole"
]
}
]
},
"Path": "/"
}
},
"OpsWorksInstanceProfile": {
"Type": "AWS::IAM::InstanceProfile",
"Properties": {
"Path": "/",
"Roles": [
{
"Ref": "OpsWorksInstanceRole"
}
]
}
}
},
"Outputs" : {
"StackId" : {
"Value" : { "Ref" : "myStack" }
},
"AppId" : {
"Value" : { "Ref" : "myApp" }
}
}
}