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

Created on 14 Jan 2020  路  12Comments  路  Source: aws/aws-sam-cli

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
stagwaiting-for-release

Most helpful comment

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

All 12 comments

This problem also happens to me.

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

@dnorth98 how do you deploy without building first?

@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 how do you deploy without building first?

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

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

@awood45 any idea when that will be released?

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

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.

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

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nicosuave picture nicosuave  路  44Comments

dinvlad picture dinvlad  路  27Comments

enghwa picture enghwa  路  25Comments

GeoffreyBooth picture GeoffreyBooth  路  29Comments

ericallam picture ericallam  路  24Comments