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

chore(apprunner): add validation cpu and memory for app runner #25877

Merged
merged 8 commits into from
Jun 12, 2023

Conversation

go-to-k
Copy link
Contributor

@go-to-k go-to-k commented Jun 7, 2023

This PR adds the same validation for the App Runner's CPU and Memory values as CloudFormation's input patterns.

Closes #25872


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented Jun 7, 2023

@github-actions github-actions bot added beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 labels Jun 7, 2023
@aws-cdk-automation aws-cdk-automation requested a review from a team June 7, 2023 07:02
@go-to-k
Copy link
Contributor Author

go-to-k commented Jun 7, 2023

I reverted this commit for the following reasons.

  • Make it easier to understand even if it is somewhat redundant.
  • Less mistakes when dealing with new specs.
    • e.g. even in the case of adding only the enum option and forgetting to add it to the of() validation parameter, the test can still detect the error.
  • Even static variable definitions are secured by defining them through a safe of() with validation.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jun 7, 2023
@go-to-k
Copy link
Contributor Author

go-to-k commented Jun 7, 2023

The AWS CodeBuild CI Report failed with internal health check errors...

time="2023-06-07T09:58:28.630630240Z" level=error msg="healthcheck failed fatally"

#25877 (comment)

@go-to-k
Copy link
Contributor Author

go-to-k commented Jun 7, 2023

I would try to make it more type safe, but guess what?

It is a union type of input-able values, and since it is string-compatible, it does not affect existing implementations and is not a destructive change.

9968af0

If not, I will revert to the previous commit.

Considering languages other than TypeScript (e.g. Python), maybe the previous one is better?

/**
* CPU input patterns for App Runner service
*/
export type CpuPatternType = '256' | '512' | '1024' | '2048' | '4096' | '0.25 vCPU' | '0.5 vCPU' | '1 vCPU' | '2 vCPU' | '4 vCPU'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you have guessed, this doesn't work for languages other than TypeScript. Take a look at:

export class Cpu {
/**
* 0.25 vCPU
*/
public static readonly QUARTER_VCPU = Cpu.of('0.25 vCPU');
/**
* 0.5 vCPU
*/
public static readonly HALF_VCPU = Cpu.of('0.5 vCPU');
/**
* 1 vCPU
*/
public static readonly ONE_VCPU = Cpu.of('1 vCPU')
/**
* 2 vCPU
*/
public static readonly TWO_VCPU = Cpu.of('2 vCPU')
/**
* 4 vCPU
*/
public static readonly FOUR_VCPU = Cpu.of('4 vCPU')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@otaviomacedo

Thanks for your review. I reverted to the previous commit.

So please review again.

/**
* Memory input patterns for App Runner service
*/
export type MemoryPatternType = '512' | '1024' | '2048' | '3072' | '4096' | '6144' | '8192' | '10240' | '12288' | '0.5 GB' | '1 GB' | '2 GB' | '3 GB' | '4 GB' | '6 GB' | '8 GB' | '10 GB' | '12 GB';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same kind of solution could be used here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted same as above comments.

Revert "chore: change CpuPatternType name"

This reverts commit da7b775.

Revert "chore: change types for of options"

This reverts commit 9968af0.
@mergify mergify bot dismissed otaviomacedo’s stale review June 9, 2023 04:34

Pull request has been modified.

@mergify
Copy link
Contributor

mergify bot commented Jun 12, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: f8730af
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit e6073fc into aws:main Jun 12, 2023
@mergify
Copy link
Contributor

mergify bot commented Jun 12, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@go-to-k go-to-k deleted the chore/validate-apprunner-cpu-and-memory branch June 12, 2023 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@aws-cdk_aws-apprunner-alpha: Invalid cpu or memory should be validated
3 participants