aws-sam-cli icon indicating copy to clipboard operation
aws-sam-cli copied to clipboard

AWS::Serverless::Api property Domain not recognized by sam-cli

Open alexx666 opened this issue 6 years ago • 12 comments

Description

When running sam validate on a tamplate containing a AWS::Serverless::Api resource with the Domain property configured it fails to recognize it upon validation, thorwing a property X not defined for resource of type Y error.

Steps to reproduce

  1. Create a SAM template containing an AWS::Serverless::Api resource. For example:
  ApiGateway:
    Type: AWS::Serverless::Api
    Properties:
      Name: !Sub ${AWS::StackName}-gateway
      StageName: test
      EndpointConfiguration: REGIONAL
      Domain:
        BasePath:
          - /test
        CertificateArn: !Ref CustomDomainCertificateArn
        DomainName: !Ref CustomDomainName
      DefinitionBody:
        Fn::Transform:
          Name: AWS::Include
          Parameters:
            Location: swagger.yml
  1. Run sam validate

Observed result

Execution throws the following error:

Error: [InvalidResourceException('ApiGateway', 'property Domain not defined for resource of type AWS::Serverless::Api')] ('ApiGateway', 'property Domain not defined for resource of type AWS::Serverless::Api')

Expected result

A successfull template validation (Considering that all unrelated resources and properties have been configured correctly).

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Mac
  2. sam --version: 0.40.0

alexx666 avatar Jan 14 '20 10:01 alexx666

This problem also happens to me.

xiaoronglv avatar Jan 20 '20 13:01 xiaoronglv

Looks like sam build also doesn't work with the domain. Deploy works just fine though.

dnorth98 avatar Jan 21 '20 21:01 dnorth98

@dnorth98 how do you deploy without building first?

maduxi avatar Jan 22 '20 09:01 maduxi

@dnorth98 how do you deploy without building first?

You only need to build if your function uses external modules. Mine doesn't (simple python functions that connect to DynamoDB and Kinesis). Create template with domain, sam deploy and voila. I'm guessing the deploy doesn't run through the same path as the build and validate (it is doing some kind of validate though).

For now, I'm going to have to rip out the domain stuff and add it using regular CFN a la https://github.com/awslabs/serverless-application-model/issues/40#issuecomment-411316776

dnorth98 avatar Jan 22 '20 13:01 dnorth98

@dnorth98 how do you deploy without building first?

building works, but validating and local start-api is not.

voathnak avatar Jan 22 '20 13:01 voathnak

This is a new feature in SAM Translator 1.20.1, which will be supported with the next release.

awood45 avatar Jan 28 '20 17:01 awood45

@awood45 any idea when that will be released?

jamie-burks avatar Jan 29 '20 23:01 jamie-burks

Why would they put it an all the docs if the feature isn't available yet!?

skrollworks avatar Feb 02 '20 12:02 skrollworks

Why would they put it an all the docs if the feature isn't available yet!?

The feature is currently available in SAM not in SAM CLI.

timoschilling avatar Feb 03 '20 09:02 timoschilling

Now it works with the latest SAM CLI version 0.41.0. I think you can close this issue.

darylounet avatar Feb 06 '20 09:02 darylounet

Yes, the "validate" passes now, but I'm not convinced that using the Domain property is a complete solution as described in the workaround in https://github.com/awslabs/serverless-application-model/issues/40. The API custom domain name is created, but apparently you can't create the Route53 hosted zone and record sets just using AWS::Serverless:Api Domain

jamie-burks avatar Feb 06 '20 13:02 jamie-burks

This was released with aws-sam-cli 0.41.0 yesterday afternoon, closing.

awood45 avatar Feb 06 '20 17:02 awood45