Aws-sam-cli: Property EventInvokeConfig not defined for resource of type AWS::Serverless::Function

Created on 24 Jan 2020  路  8Comments  路  Source: aws/aws-sam-cli

Description

Briefly describe the bug you are facing.
Serverless function definition with "EventInvokeConfig" section which should be supported according to the AWS Sam documentation leads to validiation and build error.

Steps to reproduce

Provide steps to replicate.

TestFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: src/test
      EventInvokeConfig:
        DestinationConfig:
          OnFailure:
            Destination: !Ref TestDLQ
            Type: SQS
        MaximumEventAgeInSeconds: 60
        MaximumRetryAttempts: 2

Observed result

InvalidResourceException('TestFunction',_ 'property EventInvokeConfig not defined for resource of type AWS::Serverless::Function')]

Please provide command output with --debug flag set.
sam validate --profile ...
sam build

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

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

Add --debug flag to command you are running

stagwaiting-for-release

Most helpful comment

I think the issue is due to aws-sam-cli 0.40.0 has requirement aws-sam-translator==1.19.1, but Lambda destinations support was included in aws-sam-translator==1.20.0 (https://github.com/awslabs/serverless-application-model/releases/tag/v1.20.0)

All 8 comments

I'm facing the same issue.
sam validate command fails.
is this the problem of version??

OS: amazonlinux2
Linux 81d07b382f95 4.9.184-linuxkit #1 SMP Tue Jul 2 22:58:16 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

# sam --version
SAM CLI, version 0.40.0

case1 (OK) template without EventInvokeConfig

# testcase1.yaml
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Description: test
Resources:
  testFunc:
    Type: AWS::Serverless::Function
    Properties:
      Description: test
      Runtime: python3.7
      Handler: app.lambda_handler
      CodeUri: ./src/test
      Tracing: Active
      # EventInvokeConfig:
      #   MaximumRetryAttempts: 0
# sam validate --template ./testcase1.yaml --debug
Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
Translated template is:
AWSTemplateFormatVersion: 2010-09-09
Description: test
Resources:
  testFunc:
    Properties:
      Code:
        S3Bucket: bucket
        S3Key: value
      Description: test
      Handler: app.lambda_handler
      Role:
        Fn::GetAtt:
        - testFuncRole
        - Arn
      Runtime: python3.7
      Tags:
      - Key: lambda:createdBy
        Value: SAM
      TracingConfig:
        Mode: Active
    Type: AWS::Lambda::Function
  testFuncRole:
    Properties:
      AssumeRolePolicyDocument:
        Statement:
        - Action:
          - sts:AssumeRole
          Effect: Allow
          Principal:
            Service:
            - lambda.amazonaws.com
        Version: '2012-10-17'
      ManagedPolicyArns:
      - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
      - arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess
    Type: AWS::IAM::Role

/tmp/testcase1.yaml is a valid SAM Template
Sending Telemetry: {'metrics': [{'commandRun': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam validate', 'duration': 11766, 'exitReason': 'success', 'exitCode': 0, 'requestId': 'be406ff4-6764-4709-8e5e-5723f1eb9a37', 'installationId': '1941c3dd-c906-40e7-89c4-224a92535547', 'sessionId': 'f1cf6a4c-5a26-4f7e-bda9-d771eb1779b9', 'executionEnvironment': 'CLI', 'pyversion': '3.7.4', 'samcliVersion': '0.40.0'}}]}
HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)



md5-0877425dfae2700b5a17b6162f77ae82



# testcase2.yaml
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Description: test
Resources:
  testFunc:
    Type: AWS::Serverless::Function
    Properties:
      Description: test
      Runtime: python3.7
      Handler: app.lambda_handler
      CodeUri: ./src/test
      Tracing: Active
      EventInvokeConfig:
        MaximumRetryAttempts: 0



md5-94f885de22a4626f48582d7c4054ee51



# sam validate --template ./testcase2.yaml --debug
Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
Template provided at '/tmp/testcase2.yaml' was invalid SAM Template.
Sending Telemetry: {'metrics': [{'commandRun': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam validate', 'duration': 5198, 'exitReason': 'InvalidSamTemplateException', 'exitCode': 1, 'requestId': 'a511578c-4030-4f25-9f9e-6c4ed1c679a7', 'installationId': '1941c3dd-c906-40e7-89c4-224a92535547', 'sessionId': '21623945-d91f-48f1-a311-4ce4793d5bef', 'executionEnvironment': 'CLI', 'pyversion': '3.7.4', 'samcliVersion': '0.40.0'}}]}
HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
Error: [InvalidResourceException('testFunc', 'property EventInvokeConfig not defined for resource of type AWS::Serverless::Function')] ('testFunc', 'property EventInvokeConfig not defined for resource of type AWS::Serverless::Function')
# 

I think the issue is due to aws-sam-cli 0.40.0 has requirement aws-sam-translator==1.19.1, but Lambda destinations support was included in aws-sam-translator==1.20.0 (https://github.com/awslabs/serverless-application-model/releases/tag/v1.20.0)

@tasiogr that's right! my aws-sam-translator was 1.19.1
after I upgrade it to 1.20.1 it's working with no error, thank you!

it seems already merged at #1680, right?

it seems already merged at #1680, right?

Yes, but it was merged after the latest release. It will be in the next release.

Is there any workaround for this?

It's been 3 weeks since 1.2 was released. How big a delay should we anticipate? I've got a template that is correct and works and deploys correctly, but I can't use with start local api.

Blocking local development for (as far as I can see) precisely zero benefit is rather frustrating.

My team is also blocked by this.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

XDanny322 picture XDanny322  路  3Comments

debuggins picture debuggins  路  4Comments

Caian picture Caian  路  3Comments

drumadrian picture drumadrian  路  3Comments

red8888 picture red8888  路  3Comments