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

replace with HttpApi since it is cheapier #8

Open
github-actions bot opened this issue Sep 8, 2023 · 0 comments
Open

replace with HttpApi since it is cheapier #8

github-actions bot opened this issue Sep 8, 2023 · 0 comments
Labels

Comments

@github-actions
Copy link

github-actions bot commented Sep 8, 2023

https://api.github.com/vorant94/sofash/blob/fcb3ff714b19baf963f745027eebdd11e63af32c/apps/infra/src/app/server.stack.ts#L39

import { NestedStack } from 'aws-cdk-lib';
import { type Construct } from 'constructs';
import { Code, Function, Runtime } from 'aws-cdk-lib/aws-lambda';
import { SubnetType, type Vpc } from 'aws-cdk-lib/aws-ec2';
import { LambdaIntegration, RestApi } from 'aws-cdk-lib/aws-apigateway';
import path from 'path';
import { RetentionDays } from 'aws-cdk-lib/aws-logs';

export class ServerStack extends NestedStack {
  readonly restApi: RestApi;

  constructor(scope: Construct, vpc: Vpc) {
    super(scope, ServerStack.name);

    const handler = new Function(this, Function.name, {
      vpc,
      vpcSubnets: { subnetType: SubnetType.PRIVATE_ISOLATED },
      code: Code.fromDockerBuild(path.resolve(`../../`), {
        imagePath: '/usr/local/sofash',
      }),
      handler: 'apps/server/dist/lambda.handler',
      runtime: Runtime.NODEJS_18_X,
      logRetention: RetentionDays.ONE_WEEK,
      environment: {
        NODE_ENV: 'PROD',
        DB_HOST: 'xxx',
        DB_USERNAME: 'xxx',
        DB_PASSWORD: 'xxx',
        MQ_HOST: 'xxx',
        TG_BOT_TOKEN: 'xxx',
        TG_BOT_WEBHOOK_URL: 'xxx',
      },
    });

    const integration = new LambdaIntegration(handler);

    // TODO remove stage name from generated URL
    //  (it is optional only with a custom domain)
    // TODO replace with HttpApi since it is cheapier
    this.restApi = new RestApi(this, RestApi.name);

    this.restApi.root.addProxy({
      anyMethod: true,
      defaultIntegration: integration,
    });
  }
}
@github-actions github-actions bot added the todo label Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

0 participants