{ "AWSTemplateFormatVersion": "2010-09-09", "Description": "Ec2ReplaceInstanceTestResourceStack", "Outputs": { "V1LoadBalancerName": { "Description": "ELB load balancer", "Value": { "Ref": "LoadBalancer" } }, "V2TargetGroupArn": { "Description": "TargetGroup", "Value": { "Ref": "TargetGroup" } }, "InstanceProfile": { "Description": "InstanceProfile", "Value": { "Ref": "InstanceProfile" } } }, "Parameters": { "VpcId": { "Description": "Vpc for load balancer", "Type": "String" } }, "Resources": { "InstanceRole": { "Metadata": { "cfn_nag": { "rules_to_suppress": [ { "id": "W11", "reason": "Unit test template - not deployed with solution" } ] } }, "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "ec2.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }, "Policies": [ { "PolicyName": "Policy0", "PolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ec2:DescribeInstances" ], "Resource": [ "*" ] } ] } } ], "Path": "/" } }, "InstanceProfile": { "Type": "AWS::IAM::InstanceProfile", "Properties": { "Roles": [ { "Ref": "InstanceRole" } ], "InstanceProfileName": { "Fn::Join": [ "-", [ "InstanceProfile", { "Ref": "AWS::StackName" } ] ] } } }, "LoadBalancer": { "Metadata": { "cfn_nag": { "rules_to_suppress": [ { "id": "W26", "reason": "Unit test template - not deployed with solution" } ] } }, "Type": "AWS::ElasticLoadBalancing::LoadBalancer", "Properties": { "AvailabilityZones": { "Fn::GetAZs": { "Ref": "AWS::Region" } }, "ConnectionDrainingPolicy": { "Enabled": "True", "Timeout": 20 }, "Listeners": [ { "InstancePort": "80", "InstanceProtocol": "HTTP", "LoadBalancerPort": "80", "Protocol": "HTTP" } ] } }, "TargetGroup": { "Type": "AWS::ElasticLoadBalancingV2::TargetGroup", "Properties": { "TargetGroupAttributes": [ { "Key": "deregistration_delay.timeout_seconds", "Value": "20" } ], "Port": "80", "Protocol": "HTTP", "VpcId": { "Ref": "VpcId" } } } } }