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

bug: resource translation fails when a ResourceValue::Object containing a nested TypeReference::Union is encountered in deserialized template #624

Open
colifran opened this issue Mar 20, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@colifran
Copy link
Contributor

colifran commented Mar 20, 2024

When a deserialized input template has a property that is a ResourceValue::Object containing a nested TypeReference::Union, the resource translation will fail because it is currently unimplemented -

other => unimplemented!("{other:?}"),

As an example, consider the following template:

ClientFunction:
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: 'pricing-client'
      Handler: client_lambda.lambda_handler
      MemorySize: 512
      Timeout: 300
      CodeUri: ./pricing-client/
      PermissionsBoundary: !Sub 'arn:aws:iam::${AWS::AccountId}:policy/GithubActionsIamResourcePermissionsBoundary'
      Role: !GetAtt LambdaExecutionRole.Arn
      Runtime: python3.11
      Events:
        ApiEvent:
          Type: Api
          Properties:
            Path: /path
            Method: get

The Events property is an event source that must contain one of the following event types: AlexaSkill, Api, CloudWatchEvent, CloudWatchLogs, Cognito, DocumentDB, DynamoDB, EventBridgeRule, HttpApi, IoTRule, Kinesis, MQ, MSK, S3, Schedule, ScheduleV2, SelfManagedKafka, SNS, SQS - https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-eventsource.html. As a result, the corresponding type is a TypeReference::Union(TypeUnion::Static([TypeReference::Named(_), ..])) which translates to meaning that the event type value must be one of the event types listed above.

We should add support for the TypeReference::Union type. This could be supported via a UnionOf struct similar to the MapOf struct used for the TypeReference::Map type. Further, we need to consider how we could collapse the union type down to a specific TypeReference::Named type based on the specific value detected.

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
2 participants