Glue使っているとSecurity Groupに自己参照の設定をしなければいけない時があります。
AWS Glue がコンポーネントと通信できるようにするには、すべての TCP ポートに対して自己参照のインバウンドルールを持つセキュリティグループを指定します。 https://docs.aws.amazon.com/ja_jp/glue/latest/dg/populate-add-connection.html
普通にCloudformationからAWS::EC2::SecurityGroup
だけで設定すると自己参照の設定はうまくいきません。
セキュリティグループのAWS::EC2::SecurityGroup
にから、インバウンドの設定を AWS::EC2::SecurityGroupIngress
で切り離せば設定できることがわかりましたので書いておきます。
--- AWSTemplateFormatVersion: "2010-09-09" Description: Security Group Self Reference Parameters: VpcId: Default: "" AllowedPattern: "^(vpc-([a-zA-Z0-9]{8,17})){0,1}$" ConstraintDescription: Must be a valid VPC ID. Type: String Resources: SelfRefSecurityGroup: Type: AWS::EC2::SecurityGroup Properties: GroupName: SelfRefTest Tags: - Key: Name Value: SelfRefTest GroupDescription: Self Reference Test VpcId: Ref: VpcId SelfRefSecurityGroupIgress: Type: AWS::EC2::SecurityGroupIngress Properties: GroupId: !GetAtt SelfRefSecurityGroup.GroupId IpProtocol: tcp FromPort: "0" ToPort: "65535" SourceSecurityGroupId: !GetAtt SelfRefSecurityGroup.GroupId