Skip to content

@aws-cdk_aws-apprunner-alpha: Invalid cpu or memory should be validated #25872

@go-to-k

Description

@go-to-k

Describe the feature

App Runner's CPU and Memory have a fixed input patterns in CloudFormation.
However, in CDK's L2 Construct (alpha), the input format is free (like Some vCPU). Tests are as follows (packages/@aws-cdk/aws-apprunner-alpha/test/service.test.ts).

test('custom cpu and memory units are allowed', () => {
  // GIVEN
  const app = new cdk.App();
  const stack = new cdk.Stack(app, 'demo-stack');
  // WHEN
  new apprunner.Service(stack, 'DemoService', {
    source: apprunner.Source.fromEcrPublic({
      imageIdentifier: 'public.ecr.aws/aws-containers/hello-app-runner:latest',
    }),
    cpu: apprunner.Cpu.of('Some vCPU'),
    memory: apprunner.Memory.of('Some GB'),
  });
  // THEN
  Template.fromStack(stack).hasResourceProperties('AWS::AppRunner::Service', {
    InstanceConfiguration: {
      Cpu: 'Some vCPU',
      Memory: 'Some GB',
    },
    NetworkConfiguration: {
      EgressConfiguration: {
        EgressType: 'DEFAULT',
      },
    },
  });
});

I would like to validate an invalid format before deploy.

Use Case

Incorrect values can be detected at the synth stage before deployment.

Proposed Solution

Create a private method for validation and call it at the constructor in the Service class.

Other Information

CFn output is the following message when deploy errors.

Properties validation failed for resource AppRunnerConstructAppRunnerService123456789 with message: #/InstanceConfiguration/Cpu: failed validation constraint for keyword [pattern]

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

v2.82.0

Environment details (OS name and version, etc.)

MacOS Ventura 13.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-apprunnerRelated to the apprunner packageeffort/mediumMedium work item – several days of effortfeature-requestA feature should be added or improved.p2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions