I want to provision an Application Load Balancer, but got an error:
Encountered unsupported property SecurityGroupId
My CloudFormation template is:
AWSTemplateFormatVersion: 2010-09-09
Description: AWS CloudFormation Sample Template for creating LoadBalancer
Parameters:
VPC2Block:
Description: VPCId of your existing Virtual Private Cloud (VPC)
Type: String
Default: vpc-0c9a732125ac08541
PublicSubnet03Block:
Description: SubnetId of an existing subnet (for the primary network in your Virtual Private Cloud VPC)
Type: String
Default: subnet-0787f34404852ceb9
Resources:
ApplicationLoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Name: MyApplicationLoadBalancer
Type: application
IpAddressType: ipv4
Scheme: internet-facing
SecurityGroupId: !Ref Albsg
SubnetId: !Ref PublicSubnet03Block
Tags:
- Key: Name
Value: ALB
HTTPListener:
Type: "AWS::ElasticLoadBalancingV2::Listener"
Properties:
LoadBalancerArn: !Ref ApplicationLoadBalancer
Port: 80
Protocol: "HTTP"
DefaultActions:
- Type: forward
TargetGroupArn: !Ref ALBTargetGroup
ALBTargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
HealthCheckIntervalSeconds: 10
HealthCheckPath: /
HealthCheckTimeoutSeconds: 5
HealthyThresholdCount: 2
Matcher:
HttpCode: 200,302
Name: MyWebServers
Port: 80
Protocol: HTTP
TargetType: instance
UnhealthyThresholdCount: 5
VpcId: !Ref VPC2Block
Albsg:
Type: 'AWS::EC2::SecurityGroup'
Properties:
GroupName: ALB-sg
GroupDescription: Security group for Load balancer
SecurityGroupIngress:
- CidrIp: 0.0.0.0/0
FromPort: '80'
IpProtocol: tcp
ToPort: '80'
Tags:
- Key: Name
Value: ALB_SG
Outputs:
TargetGroupName:
Value: !Ref ALBTargetGroup
Description: Name of Target ARN