アラキタウン

黒歴史や生き恥を切り売り

セキュリティーグループのインバウンドルールに他セキュリティーグループを設定する

SeverlessFrameworkでElasticacheを動作させるため、インバウンドルールにLambdaのセキュリティグループを設定しなければならなかったのですが、
設定の方法に迷ったのでメモ

    VPC:
      Type: AWS::EC2::VPC
      Properties:
        CidrBlock: 192.168.0.0/16
        EnableDnsSupport: 'true'
        EnableDnsHostnames: 'true'
        InstanceTenancy: default
                
    SecurityGroup:
      Type: AWS::EC2::SecurityGroup
      Properties:
        GroupDescription: SecurityGroup
        VpcId:
          Ref: VPC
    InboundRule:
      Type: 'AWS::EC2::SecurityGroupIngress'
      Properties:
        GroupId: !GetAtt SecurityGroup.GroupId
        IpProtocol: tcp
        FromPort: 11211
        ToPort: 11211
        SourceSecurityGroupId: 
          Ref: LambdaSecurityGroup
      
    LambdaSecurityGroup:
      Type: AWS::EC2::SecurityGroup
      Properties:
        GroupDescription: Lambda
        VpcId: 
          Ref: VPC