2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CloudFormationでELBからのアクセスを許可するEC2 SecurityGroupを作成する

Posted at
  • AWS CloudFormationで、ELBからのアクセスを許可するEC2 SecurityGroupを作成するテンプレートを作成してみました。
  • 前提として非VPC環境でEC2 Security GroupのInboundのSourceにamazon-elb/amazon-elb-sgを設定するとELBからのアクセスのみを許可します。
  • ポイントはSourceSecurityGroupNameにamazon-elb-sg、SourceSecurityGroupOwnerIdにamazon-elbを設定することみたいです。
JSON
{
  "AWSTemplateFormatVersion" : "2010-09-09",

  "Description" : "build EC2 SecurityGroup",
  
  "Resources" : {
    "MySecurityGroup" : {
      "Type" : "AWS::EC2::SecurityGroup",
      "Properties" : {
        "GroupDescription" : "SecurityGroupTest",
        "SecurityGroupIngress": [{
          "IpProtocol": "tcp",
          "CidrIp": "0.0.0.0/0",
          "FromPort": "22",
          "ToPort": "22"
        },
        {
          "IpProtocol": "tcp",
          "SourceSecurityGroupName": "amazon-elb-sg",
          "SourceSecurityGroupOwnerId" : "amazon-elb", 
          "FromPort": "80",
          "ToPort": "80"
        }]
      }
    }
  },
  
  "Outputs" : {
    "CreatedSecurityGroup" : {
      "Value" : { "Ref" : "MySecurityGroup" }
    }
  }
}

所感

  • うまいこと方法がググれなくて手当たり次第試してたどり着きました。
  • このためだけにAWSの有料サポート受けようかと思った、、、
  • 方法を知ってからググると情報が見つかる、、、
2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?