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

Customization breaks Lambda@Edge functions due to SOLUTION_ID Environment Variable #643

Open
5 tasks done
kisst opened this issue Nov 14, 2024 · 0 comments
Open
5 tasks done
Labels
bug Something isn't working

Comments

@kisst
Copy link

kisst commented Nov 14, 2024

Describe the bug
As part of the customization re-render my Lambda Function is modified by adding the SOLUTION_ID Environment Variable, ( adding the extra SSM parameters , which makes it incompatible with Lambda@Edge as they are unsupported https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-at-edge-function-restrictions.html#lambda-at-edge-restrictions-features
As far as I am considered this is a bug, as it modifies the code I have provided in a matter which makes it unusable, but it might be considered as a feature request, to be able to tell as part of the https://awslabs.github.io/landing-zone-accelerator-on-aws/latest/typedocs/latest/interfaces/___packages__aws_accelerator_config_lib_models_customizations_config.ICloudFormationStack.html stack definition that this stack should not be modified, although I believe generally this modification is unwanted for all customization.

The use-case is, a centralized route in CDN to be deployed from LZA, and to make some smarter application routing I added and inline lambda function to be deployed on the Edge.

To Reproduce
Try to deploy this simple template, as part of the customization.

AWSTemplateFormatVersion: '2010-09-09'
Resources:
  HelloWorldLambdaFunction:
    Type: 'AWS::Lambda::Function'
    Properties:
      Handler: index.lambda_handler
      Role: !GetAtt LambdaExecutionRole.Arn
      Code:
        ZipFile: |
          def lambda_handler(event, context):
              return 'Hello, World!'
      Runtime: python3.9

  LambdaExecutionRole:
    Type: 'AWS::IAM::Role'
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Principal:
              Service: [lambda.amazonaws.com]
            Action: ['sts:AssumeRole']
      ManagedPolicyArns:
        - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole

Check the deployed function's Env variables

Expected behavior
Lambda functions or in general customisation codes are left alone, and not modified any further then needed ( SSM parameters for solution tracking )

Please complete the following information about the solution:

  • Version: 1.10
  • Region: us-east-1
  • Was the solution modified from the version published on this repository?: No
  • Have you checked your service quotas for the services this solution uses?: NA
  • Were there any errors in the CloudWatch Logs?: NA
@kisst kisst added the bug Something isn't working label Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant