API GatewayのリソースポリシーでのRefの使い方
前回のメモを書いた後、そういえばCustomStatements
で自由にPolicyが書けるようになっていたのを思い出した。
作り直したテンプレート(抜粋)
Resource: MyApi: Type: AWS::Serverless::Api Properties: StageName: hoge EndpointConfiguration: PRIVATE Auth: ResourcePolicy: CustomStatements: - Effect: Deny Principal: "*" Action: execute-api:Invoke Condition: StringNotEquals: aws:SourceVpce: Ref: MyEndpoint MyEndpoint: Type: AWS::EC2::VPCEndpoint Properties: VpcId: vpc-1234 VpcEndpointType: Interface SubnetIds: - subnet-1234 ServiceName: Fn::Sub: com.amazonaws.${AWS::Region}.execute-api SecurityGroup: - sg-1234
これで無事通りますね👍