Skip to content

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

Open
@colifran

Description

@colifran

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions