Skip to content

Instantly share code, notes, and snippets.

@kkarimi
Created July 5, 2024 13:11
Show Gist options
  • Save kkarimi/76dc0635633213a17ffdac78ca885a80 to your computer and use it in GitHub Desktop.
Save kkarimi/76dc0635633213a17ffdac78ca885a80 to your computer and use it in GitHub Desktop.

Revisions

  1. kkarimi created this gist Jul 5, 2024.
    35 changes: 35 additions & 0 deletions apprunner_cdk.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    import * as cdk from '@aws-cdk/core';
    import { Service, Source, GitHubConnection, ConfigurationSourceType, Runtime } from '../lib';

    const app = new cdk.App();

    const stack = new cdk.Stack(app, 'integ-apprunner');

    // Scenario 4: Create the service from Github. Make sure you specify a valid connection ARN.
    const connectionArn = process.env.CONNECTION_ARN || 'MOCK';
    const service4 = new Service(stack, 'Service4', {
    source: Source.fromGitHub({
    repositoryUrl: 'https://github.com/aws-containers/hello-app-runner',
    branch: 'main',
    configurationSource: ConfigurationSourceType.REPOSITORY,
    connection: GitHubConnection.fromConnectionArn(connectionArn),
    }),
    });
    new cdk.CfnOutput(stack, 'URL4', { value: `https://${service4.serviceUrl}` });

    // Scenario 5: Create the service from Github with configuration values override.
    const service5 = new Service(stack, 'Service5', {
    source: Source.fromGitHub({
    repositoryUrl: 'https://github.com/aws-containers/hello-app-runner',
    branch: 'main',
    configurationSource: ConfigurationSourceType.API,
    codeConfigurationValues: {
    runtime: Runtime.PYTHON_3,
    port: '8000',
    startCommand: 'python app.py',
    buildCommand: 'yum install -y pycairo && pip install -r requirements.txt',
    },
    connection: GitHubConnection.fromConnectionArn(connectionArn),
    }),
    });
    new cdk.CfnOutput(stack, 'URL5', { value: `https://${service5.serviceUrl}` });