Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sam: cdk synth is missing prop for CfnFunction #29297

Open
AmazingDreams opened this issue Feb 26, 2024 · 5 comments
Open

sam: cdk synth is missing prop for CfnFunction #29297

AmazingDreams opened this issue Feb 26, 2024 · 5 comments
Labels
@aws-cdk/aws-sam Related to AWS Serverless Application Model @aws-cdk/core Related to core CDK functionality bug This issue is a bug. effort/medium Medium work item – several days of effort p1

Comments

@AmazingDreams
Copy link

Description:

I am trying to setup an SQS event handler with ReportBatchItemFailures enabled. I am using CDK. However, the option will still be disabled.

Steps to reproduce:

I am using this in CDK template:

        new sam.CfnFunction(this, 'some-function', {
            events: {
                sqs: {
                    type: 'SQS',
                    properties: {
                        queue: this.queue.queueArn,
                        batchSize: 10,
                        functionResponseTypes: [ 'ReportBatchItemFailures' ],
                    }
                }
            }
        });

Observed result:

The function response types are not inserted into the generated template:

  somefunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: somefunction
      Events:
        sqs:
          Properties:
            BatchSize: 10
            Queue:
              Fn::GetAtt:
              - somequeue
              - Arn
          Type: SQS

Expected result:

I expect the ReportBatchItemFailures to be injected into the generated template:

          Properties:
            BatchSize: 10
            Queue:
              Fn::GetAtt:
              - somequeue
              - Arn
            FunctionResponseTypes:
              - ReportBatchItemFailures

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

  1. OS: Windows
  2. sam --version:
  3. AWS region: eu-west-1
{
  "version": "1.109.0",
  "system": {
    "python": "3.11.7",
    "os": "Windows-10-10.0.22631-SP0"
  },
  "additional_dependencies": {
    "docker_engine": "Not available",
    "aws_cdk": "Not available",
    "terraform": "1.7.3"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}

Add --debug flag to command you are running

@AmazingDreams AmazingDreams changed the title Bug: SAM + CDK: ReportBatchItemFailures does not work Bug: SAM + CDK: SQS ReportBatchItemFailures does not work Feb 27, 2024
@jysheng123 jysheng123 transferred this issue from aws/aws-sam-cli Feb 28, 2024
@jysheng123
Copy link

Hi, thanks for bringing up this issue, since you are creating the SAM template from CDK directly, this is not being used in SAM CLI, sending this over to the appropriate SAM repo.

@AmazingDreams
Copy link
Author

Seems related to this issue aws/serverless-application-model#3322

I guess CDK does not have the latest model setup?

@GavinZZ
Copy link
Contributor

GavinZZ commented Feb 28, 2024

Hi there, thanks for reaching out. I tested with this template

Resources:
  somefunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: nodejs12.x
      CodeUri: s3://bucket/key
      Events:
        sqs:
          Properties:
            BatchSize: 10
            Queue:
              Fn::GetAtt:
              - somequeue
              - Arn
          Type: SQS

SAM is correctly transforming the template and the resulted event source mapping has batch size defined. This should be forwarded to AWS CDK repo.

@GavinZZ GavinZZ transferred this issue from aws/serverless-application-model Feb 28, 2024
@ashishdhingra ashishdhingra added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 14, 2024
@pahud
Copy link
Contributor

pahud commented Mar 15, 2024

Yes I can reproduce this issue

    new sam.CfnFunction(this, 'some-function', {
      events: {
          sqs: {
              type: 'SQS',
              properties: {
                  queue: 'dummyArn',
                  batchSize: 10,
                  functionResponseTypes: ['foo'],
              }
          }
      }
    });

would synthesize into

  somefunction:
    Type: AWS::Serverless::Function
    Properties:
      Events:
        sqs:
          Properties:
            BatchSize: 10
            Queue: dummyArn
          Type: SQS

And functionResponseTypes is missing in the template.

@pahud pahud added @aws-cdk/core Related to core CDK functionality @aws-cdk/aws-sam Related to AWS Serverless Application Model labels Mar 15, 2024
@pahud pahud changed the title Bug: SAM + CDK: SQS ReportBatchItemFailures does not work sam: cdk synth is missing prop for CfnFunction Mar 15, 2024
@pahud pahud added p1 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Mar 15, 2024
@AmazingDreams
Copy link
Author

Actually I am encountering more and more things that seem to be not included in CDK. As if the definitions for SAM are out of date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-sam Related to AWS Serverless Application Model @aws-cdk/core Related to core CDK functionality bug This issue is a bug. effort/medium Medium work item – several days of effort p1
Projects
None yet
Development

No branches or pull requests

5 participants