constructor()

in source/4-landing-page-with-feedback-api/infrastructure/lib/frontend/frontend-config.ts [15:39]


  constructor(scope: core.Construct, id: string, props: FrontendConfigProps) {
    super(scope, id);

    this.config = JSON.stringify({
        API_URL: props.api.url,
    });

    new cr.AwsCustomResource(this, "WriteS3ConfigFile", {
        onUpdate: {
            service: "S3",
            action: "putObject",
            parameters: {
                Body: this.config,
                Bucket: props.siteBucket.bucketName,
                Key: "config.json",
            },
            physicalResourceId: cr.PhysicalResourceId.of(
                Date.now().toString()
            ), // always write this file
        },
        policy: cr.AwsCustomResourcePolicy.fromSdkCalls({
            resources: cr.AwsCustomResourcePolicy.ANY_RESOURCE,
        }),
    });
  }