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

feat(amplify): enables apps hosted with server side rendering #26861

Merged
merged 6 commits into from
Aug 25, 2023

Conversation

srquinn21
Copy link
Contributor

@srquinn21 srquinn21 commented Aug 23, 2023

Problem:

The Amplify App L2 construct does not support the ability for customers to configure a SSR app without reaching down into the lower level L1.

Solution:

Expose the platform field used to set SSG vs SSR hosted applications. Do not expose WEB_DYNAMIC as SSRv1 is on the deprecation path.

Testing Done:

  • yarn build+test
  • added new tests for platform field
  • updated snapshots for new default value

Closes #24076 and #23325


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

Problem:
The Amplify App L2 construct does not support the ability for customers
to configure a SSR app without reaching down into the lower level L1.

Solution:
Expose the `platform` field used to set SSG vs SSR hosted applications.
Do not expose `WEB_DYNAMIC` as SSRv1 is on the deprecation path.

Testing Done:
* yarn build+test
* updated snapshots for new default value
@aws-cdk-automation aws-cdk-automation requested a review from a team August 23, 2023 19:22
@github-actions github-actions bot added effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK labels Aug 23, 2023
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@srquinn21 srquinn21 changed the title feat(amplify) Adds platform property to App construct feat(amplify): Adds platform property to App construct Aug 23, 2023
@srquinn21 srquinn21 changed the title feat(amplify): Adds platform property to App construct feat(amplify): adds platform property to app construct Aug 23, 2023
@srquinn21 srquinn21 changed the title feat(amplify): adds platform property to app construct feat(amplify): enables apps hosted with server side rendering Aug 23, 2023
@aws-cdk-automation aws-cdk-automation dismissed their stale review August 23, 2023 19:57

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@srquinn21
Copy link
Contributor Author

@TheRealAmazonKendra As per our latest conversation, any feedback is appreciated.

@srquinn21
Copy link
Contributor Author

Example App:

import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { App as AmplifyApp, GitHubSourceCodeProvider, Platform } from '@aws-cdk/aws-amplify-alpha';
import { AwsCustomResource, AwsCustomResourcePolicy, PhysicalResourceId } from 'aws-cdk-lib/custom-resources';

export class AmplifyFullstackCdkStack extends cdk.Stack {
  private readonly deployer: AwsCustomResource;

  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    // Create an app from GitHub source
    const appName = 'AmplifyCDKApp';
    const app = new AmplifyApp(this, appName, {
      appName,
      platform: Platform.WEB_COMPUTE,
      sourceCodeProvider: new GitHubSourceCodeProvider({
        owner: 'srquinn21',
        repository: 'nextjs-blog',
        // Super important that this secret's value is created as plain text and not K/V
        // in the secret's manager console.
        oauthToken: cdk.SecretValue.secretsManager('amplify-github-token'),
      }),
    });

    // Add a branch for auto building
    const branch = app.addBranch('main');

    // Automatically build the branch on Amplify service as part of the CFN deployment
    this.deployer = new AwsCustomResource(this, 'AmplifyDeployer', {
      onUpdate: {
        service: 'Amplify',
        action: 'startJob',
        parameters: {
          appId: app.appId,
          branchName: branch.branchName,
          jobType: 'RELEASE',
        },
        physicalResourceId: PhysicalResourceId.of(Date.now().toString()),
      },
      policy: AwsCustomResourcePolicy.fromSdkCalls({
        resources: AwsCustomResourcePolicy.ANY_RESOURCE,
      }),
    });
  }
}

@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 Aug 23, 2023
Copy link
Contributor

@lpizzinidev lpizzinidev left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

@aws-cdk-automation aws-cdk-automation added pr/needs-maintainer-review This PR needs a review from a Core Team Member and removed pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Aug 24, 2023
@mergify
Copy link
Contributor

mergify bot commented Aug 25, 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 aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Aug 25, 2023
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 75856a8
  • 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 c67da83 into aws:main Aug 25, 2023
13 checks passed
@mergify
Copy link
Contributor

mergify bot commented Aug 25, 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).

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/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(aws-cdk/aws-amplify): (Add Platform property to amplify.App)
5 participants