Serverless-application-model: Stage variable not properly injected into swagger doc

Created on 20 Aug 2017  路  2Comments  路  Source: aws/serverless-application-model

I have the following resources in a SAM CloudFormation template (this template is not complete鈥攋ust showing the relevant parts):

Parameters:
  EncryptedMongoUrl:
    Type: "String"
    Description: "Encrypted MONGO_URL value."
  UserPoolName:
    Type: "String"
    Description: "Desired name of the Cognito user pool."
Resources:
  UserPool:
    Type: "AWS::Cognito::UserPool"
    Properties:
      UserPoolName: !Ref UserPoolName
      Policies:
        PasswordPolicy:
          MinimumLength: 8
          RequireLowercase: true
          RequireUppercase: true
          RequireNumbers: true
          RequireSymbols: false
  ApiGateway:
    Type: "AWS::Serverless::Api"
    DependsOn: UserPool
    Properties:
      StageName: "v1"
      DefinitionUri: "./lambda-proxy-api.yaml"
      Variables:
        GraphQLFuncName: !Ref GraphQL
        UserPoolArn: !GetAtt UserPool.Arn

Here's the lambda-proxy-api.yaml file:

---
swagger: 2.0
info:
  title: OnSpotServerlessApi
paths:
  "/graphql":
    post:
      responses: {}
      security:
      - UserPool: []
      x-amazon-apigateway-integration:
        uri: arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:xxx:function:${stageVariables.GraphQLFuncName}/invocations
        httpMethod: POST
        type: aws_proxy
securityDefinitions:
  UserPool:
    type: apiKey
    name: Authorization
    in: header
    x-amazon-apigateway-authtype: cognito_user_pools
    x-amazon-apigateway-authorizer:
      providerARNs:
      - ${stageVariables.UserPoolArn}
      type: cognito_user_pools

Oddly enough, the GraphQL function name comes through just fine, but the stageVariables.UserPoolArn does not. When the stack tries to build, I get this error:

Errors found during import: Unable to create authorizer 'UserPool': ProviderARNs need to be valid Cognito Userpools. Invalid ARNs- ${stageVariables.UserPoolArn} Unable to put method 'POST' on resource at path '/graphql': Invalid authorizer ID specified. Setting the authorization type to CUSTOM or COGNITO_USER_POOLS requires a valid authorizer.

Why does this variable interpolation not work?

All 2 comments

looks like #66 where we're told it's a problem on the apigw side.

Closing this because SAM can't do anything about it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vinkris picture vinkris  路  3Comments

feinstein picture feinstein  路  3Comments

angustohrallegrinski picture angustohrallegrinski  路  3Comments

zeroastro picture zeroastro  路  3Comments

charsleysa picture charsleysa  路  3Comments