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

feat: update event invoke config with alias #149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ojongerius
Copy link

Proposed changes

This change updates the EventInvokeConfig to point to the alias created. This means that Destinations, MaximumEventAgeInSeconds and MaximumRetryAttempts were previously only applied to the unqualified ARN instead of the alias.

Types of changes

What types of changes does your code introduce to the plugin?
Put an x in the boxes that apply

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

@ojongerius ojongerius marked this pull request as ready for review August 31, 2022 23:36
@ojongerius
Copy link
Author

ojongerius commented Aug 31, 2022

One thing to mentioned might be, I'm updating instead of adding the EventInvokeConfig. When adding an EventInvokeConfig for both unqualified and an alias, the Cloudformation validation will pass but AWS will only create one EventInvokeConfig -in this case for the unqualified only.

When generating these snippets of CF template:

    "HelloLambdaEvConfAlias": {
      "Type": "AWS::Lambda::EventInvokeConfig",
      "Properties": {
        "FunctionName": {
          "Ref": "HelloLambdaFunction"
        },
        "DestinationConfig": {
          "OnFailure": {
            "Destination": "arn:aws:sqs:ap-southeast-2:123456789:dev-primary-dlq"
          }
        },
        "Qualifier": "live",
        "MaximumEventAgeInSeconds": 1800,
        "MaximumRetryAttempts": 2
      },
      "DependsOn": "HelloWorldFunctionAliaslive"
    }

and

    "HelloLambdaEvConf": {
      "Type": "AWS::Lambda::EventInvokeConfig",
      "Properties": {
        "FunctionName": {
          "Ref": "HelloLambdaFunction"
        },
        "DestinationConfig": {
          "OnFailure": {
            "Destination": "arn:aws:sqs:ap-southeast-2:123456789:dev-primary-dlq"
          }
        },
        "Qualifier": "$LATEST",
        "MaximumEventAgeInSeconds": 1800,
        "MaximumRetryAttempts": 2
      }
    }

AWS actually would only create an Ev config for for the unqualified function:

▶ aws lambda get-function-event-invoke-config --function-name hello                 
{
    "LastModified": "2022-09-01T11:03:11.647000+12:00",
    "FunctionArn": "arn:aws:lambda:ap-southeast-2:123456789:function:hello:$LATEST",
    "MaximumRetryAttempts": 2,
    "MaximumEventAgeInSeconds": 1800,
    "DestinationConfig": {
        "OnSuccess": {},
        "OnFailure": {
            "Destination": "arn:aws:sqs:ap-southeast-2:123456789:dev-primary-dlq"
        }
    }
}

But not the alias:

▶ aws lambda get-function-event-invoke-config --function-name hello --qualifier live

An error occurred (ResourceNotFoundException) when calling the GetFunctionEventInvokeConfig operation: The function arn:aws:lambda:ap-southeast-2:123456789:function:hello:live doesn't have an EventInvokeConfig

@ojongerius
Copy link
Author

@davidgf have a moment to review?

@ojongerius
Copy link
Author

@davidgf ping! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant