AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: > Go-HttpBin-Zip Sample SAM Template for Go-HttpBin-Zip Parameters: Subnets: Type: AWS::SSM::Parameter::Value> Default: /lambda-web-adapter/e2e/subnets VpcId: Type: AWS::SSM::Parameter::Value Default: /lambda-web-adapter/e2e/vpcid CertificateArn: Type: AWS::SSM::Parameter::Value Default: /lambda-web-adapter/e2e/cert Route53HostedZone: Type: AWS::SSM::Parameter::Value Default: /lambda-web-adapter/e2e/hostedzone Route53HostedZoneId: Type: AWS::SSM::Parameter::Value Default: /lambda-web-adapter/e2e/hostedzoneid AdapterLayerArn: Type: AWS::SSM::Parameter::Value Default: /lambda-web-adapter/layer/x86_64/latest Globals: Function: Timeout: 10 Resources: RestApi: Type: AWS::Serverless::Api Properties: StageName: Prod BinaryMediaTypes: - '*~1*' Domain: CertificateArn: !Ref CertificateArn DomainName: !Sub httpbin-rest-zip.${Route53HostedZone} EndpointConfiguration: REGIONAL Route53: HostedZoneId: !Ref Route53HostedZoneId EndpointConfiguration: Type: REGIONAL HttpApi: Type: AWS::Serverless::HttpApi Properties: Domain: CertificateArn: !Ref CertificateArn DomainName: !Sub httpbin-http-zip.${Route53HostedZone} Route53: HostedZoneId: !Ref Route53HostedZoneId HttpBinFunction: Type: AWS::Serverless::Function Properties: CodeUri: ./app Handler: bootstrap Runtime: provided.al2 MemorySize: 256 Environment: Variables: AWS_LWA_ENABLE_COMPRESSION: 'true' Layers: - !Ref AdapterLayerArn Events: HttpAPIEvent: Type: HttpApi Properties: ApiId: !Ref HttpApi RestAPIRoot: Type: Api Properties: Path: / Method: ANY RestApiId: !Ref RestApi RestAPIProxy: Type: Api Properties: Path: /{proxy+} Method: ANY RestApiId: !Ref RestApi FunctionUrlConfig: AuthType: AWS_IAM Metadata: BuildMethod: makefile LoadBalancerSecurityGroup: Type: AWS::EC2::SecurityGroup Properties: GroupDescription: Allow http to client host VpcId: !Ref VpcId SecurityGroupIngress: - IpProtocol: tcp FromPort: 443 ToPort: 443 CidrIp: 0.0.0.0/0 LoadBalancer: Type: AWS::ElasticLoadBalancingV2::LoadBalancer Properties: Scheme: internet-facing Subnets: !Ref Subnets SecurityGroups: - !Ref LoadBalancerSecurityGroup HttpBinFunctionInvokePermission: Type: AWS::Lambda::Permission Properties: FunctionName: !GetAtt HttpBinFunction.Arn Action: 'lambda:InvokeFunction' Principal: elasticloadbalancing.amazonaws.com TargetGroup: Type: AWS::ElasticLoadBalancingV2::TargetGroup DependsOn: HttpBinFunctionInvokePermission Properties: TargetType: lambda Targets: - Id: !GetAtt HttpBinFunction.Arn HttpsListener: Type: 'AWS::ElasticLoadBalancingV2::Listener' Properties: Certificates: - CertificateArn: !Ref CertificateArn DefaultActions: - TargetGroupArn: !Ref TargetGroup Type: forward LoadBalancerArn: !Ref LoadBalancer Port: 443 Protocol: HTTPS AlbDNSRecord: Type: AWS::Route53::RecordSet Properties: HostedZoneId : !Ref Route53HostedZoneId Name: !Sub httpbin-alb-zip.${Route53HostedZone} AliasTarget: DNSName: !GetAtt LoadBalancer.DNSName HostedZoneId: !GetAtt LoadBalancer.CanonicalHostedZoneID Type: A RestApiEndpoint: Type: AWS::SSM::Parameter Properties: Name: /lambda-web-adapter/e2e/httpbin/zip/rest-api-endpoint Description: 'Rest API Endpoint for HttpBin function' Type: String Value: !Sub "https://httpbin-rest-zip.${Route53HostedZone}/" HttpApiEndpoint: Type: AWS::SSM::Parameter Properties: Name: /lambda-web-adapter/e2e/httpbin/zip/http-api-endpoint Description: 'Http API Endpoint for HttpBin function' Type: String Value: !Sub "https://httpbin-http-zip.${Route53HostedZone}/" AlbEndpoint: Type: AWS::SSM::Parameter Properties: Name: /lambda-web-adapter/e2e/httpbin/zip/alb-endpoint Description: 'ALB Endpoint for HttpBin function' Type: String Value: !Sub "https://${AlbDNSRecord}/" FunctionUrl: Type: AWS::SSM::Parameter Properties: Name: /lambda-web-adapter/e2e/httpbin/zip/function-url Description: 'Function URL for HttpBin function' Type: String Value: !GetAtt HttpBinFunctionUrl.FunctionUrl Outputs: HttpBinHttpApi: Description: "API Gateway Http API endpoint URL for default stage for HttpBin function" Value: !Sub "https://httpbin-http-zip.${Route53HostedZone}/" HttpBinRestApi: Description: "API Gateway Rest API endpoint URL for Prod stage for HttpBin function" Value: !Sub "https://httpbin-rest-zip.${Route53HostedZone}/" HttpBinAlbDNS: Description: "Application Load Balancer for HttpBin function" Value: !Sub "https://${AlbDNSRecord}/" HttpBinFunctionUrl: Description: "Function URL for HttpBin function" Value: !GetAtt HttpBinFunctionUrl.FunctionUrl