Open damianlluch opened 6 months ago
"aws-cdk": "^2.138.0",
"aws-cdk-lib": "2.138.0",
I updated those packages, and it went well. I have checked the available versions of RDS in AWS, and everything is perfect.
infra/constructs/aurora-database/aurora-database.construct.ts
import * as rds from 'aws-cdk-lib/aws-rds';
import { Aspects } from 'aws-cdk-lib';
import { InstanceType, SubnetType } from 'aws-cdk-lib/aws-ec2';
import { CfnDBCluster } from 'aws-cdk-lib/aws-rds';
import { Construct } from 'constructs';
import { AuroraDatabaseProps } from './props/aurora-database.props';
import { createName } from '../../utils/create-name';
export class AuroraDatabase extends Construct {
databaseCluster: rds.DatabaseCluster;
constructor(
scope: Construct,
id: string,
auroraDatabaseProps: AuroraDatabaseProps,
) {
super(scope, id);
// get vpc and security group
const { securityGroup, vpc } = auroraDatabaseProps;
// create a aurora db cluster serverless v2 postgres
const DATABASE_CLUSTER_NAME = createName('cluster', auroraDatabaseProps);
this.databaseCluster = new rds.DatabaseCluster(
this,
DATABASE_CLUSTER_NAME,
{
instances: 1,
iamAuthentication: true,
port: 5432,
engine: rds.DatabaseClusterEngine.auroraPostgres({
version: rds.AuroraPostgresEngineVersion.VER_13_13,
}),
storageEncrypted: true,
instanceProps: {
vpc: vpc,
instanceType: new InstanceType('serverless'),
autoMinorVersionUpgrade: true,
publiclyAccessible: false,
securityGroups: [securityGroup],
vpcSubnets: vpc.selectSubnets({
subnetType: SubnetType.PUBLIC, // use the public subnet created above for the db
}),
},
},
);
// add capacity to the db cluster to enable scaling
Aspects.of(this.databaseCluster).add({
visit(node) {
if (node instanceof CfnDBCluster) {
node.serverlessV2ScalingConfiguration = {
minCapacity: 0.5, // min capacity is 0.5 vCPU
maxCapacity: 1, // max capacity is 1 vCPU (default)
};
}
},
});
}
}
A couple of parameters are marked as deprecated, as an additional comment.
The question I have is how can I test this in AWS (i.e. the code in production)? If you can help me how to do it. Thanks
Hi Damianlluch!
We are happy that this repository is useful to you! We're here to support you as you move forward with bringing it to production.
It seems like we've hit a snag regarding the availability of Aurora PostgreSQL version 13.6. The error message you're encountering reads:
The resource handler returned the message: "Cannot find version 13.6 for aurora-postgresql (service: Rds, status code: 400, request ID: 898b8e9a-a094-4bcc-a3d3-b82f697aebc5)" (RequestToken: 8b6f5b5a -ce02-0a6e-7e6e-131c544c76c3)`
This indicates that the specified version of Aurora PostgreSQL isn't currently accessible. It's possible that this is due to your region's settings.
To verify the available engines in your region, you can use the following command. Just make sure to replace "us-east-2" with your correct region:
aws rds describe-db-engine-versions --engine aurora-postgresql --query '*[].[EngineVersion]' --output text --region us-east-2
I hope this helps clarify the situation for you. Feel free to reach out if you have any other questions or run into further issues. We're here to assist!
Note, we are using aurora serverless v2.
If this helps you, here is a configuration used by a client of ours with a database using instances (no serverless)
import { Aspects } from 'aws-cdk-lib';
import {
InstanceClass,
InstanceSize,
InstanceType,
SubnetType,
} from 'aws-cdk-lib/aws-ec2';
import * as rds from 'aws-cdk-lib/aws-rds';
import { CfnDBCluster } from 'aws-cdk-lib/aws-rds';
import { Construct } from 'constructs';
import { createName } from '../../utils/create-name';
import { AuroraDatabaseProps } from './props/aurora-database.props';
export class AuroraDatabase extends Construct {
databaseCluster: rds.DatabaseCluster;
constructor(
scope: Construct,
id:string,
auroraDatabaseProps: AuroraDatabaseProps,
) {
super(scope, id);
// get vpc and security group
const { securityGroup, vpc } = auroraDatabaseProps;
// create a aurora db cluster serverless v2 postgres
const DATABASE_CLUSTER_NAME = createName('cluster', auroraDatabaseProps);
this.databaseCluster = new rds.DatabaseCluster(
this,
DATABASE_CLUSTER_NAME,
{
instances: 1,
iamAuthentication: true,
port: 5432,
engine: rds.DatabaseClusterEngine.auroraPostgres({
version: rds.AuroraPostgresEngineVersion.VER_16_1,
}),
storageEncrypted: true,
storageType: rds.DBClusterStorageType.AURORA,
instanceProps: {
vpc:vpc,
instanceType: InstanceType.of(InstanceClass.T4G, InstanceSize.MEDIUM),
autoMinorVersionUpgrade: true,
securityGroups: [securityGroup],
vpcSubnets: vpc.selectSubnets({
subnetType: SubnetType.PUBLIC, // use the public subnet created above for the db
}),
},
},
);
}
}
Hi, I was able to fix it by updating the dependencies.
How can I test the API in AWS ? or see the Swagger itself ?
Thanks
I have deployed with CDK, and I only have this. The auth APIs are not there, why?
Upon reviewing the code again, I noticed an error in the infrastructure code in the applications layer, where only the users service is being served at the root, excluding Swagger and Auth declarations.
We have a production version with these issues resolved. We'll make the necessary corrections and update the boilerplate. Additionally, we'll update packages like AWS Signer to the latest AWS SDK version and address other minor details identified.
ETA: I hope to bring updates tomorrow.
Perfect, great, thank you
Include these corrections in the refactoring for version 0.1.0, which has been completed and is under review, tomorrow we will start a review process with @lhgrigio @junior-anzolin
We have released v0.1.0, containing the fix for this issue. I suggest you run cdk destroy on the previous version and deploy everything again.
Perfect, I'll try it and let you know. Thanks!
Hi!
fail with cdk synth
[WARNING] aws-cdk-lib.aws_rds.DatabaseClusterProps#instanceProps is deprecated.
- use writer and readers instead
This API will be removed in the next major release.
[WARNING] aws-cdk-lib.aws_rds.DatabaseClusterProps#instances is deprecated.
- use writer and readers instead
This API will be removed in the next major release.
[+] Building 1.4s (14/14) FINISHED docker:desktop-linux
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.34kB 0.0s
=> [internal] load metadata for public.ecr.aws/sam/build-nodejs16.x:latest 1.3s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [ 1/10] FROM public.ecr.aws/sam/build-nodejs16.x:latest@sha256:7f3571a92b71470bfa4e73348c3ce61cd513a4a8b43b0fc17e46cb1203afcde1 0.0s
=> CACHED [ 2/10] RUN npm install --global yarn@1.22.5 0.0s
=> CACHED [ 3/10] RUN npm install --global pnpm@7.30.5 0.0s
=> CACHED [ 4/10] RUN npm install --global typescript 0.0s
=> CACHED [ 5/10] RUN npm install --global --unsafe-perm=true esbuild@0 0.0s
=> CACHED [ 6/10] RUN mkdir /tmp/npm-cache && chmod -R 777 /tmp/npm-cache && npm config --global set cache /tmp/npm-cache 0.0s
=> CACHED [ 7/10] RUN mkdir /tmp/yarn-cache && chmod -R 777 /tmp/yarn-cache && yarn config set cache-folder /tmp/yarn-cache 0.0s
=> CACHED [ 8/10] RUN mkdir /tmp/pnpm-cache && chmod -R 777 /tmp/pnpm-cache && pnpm config --global set store-dir /tmp/pnpm-cache 0.0s
=> CACHED [ 9/10] RUN npm config --global set update-notifier false 0.0s
=> CACHED [10/10] RUN /sbin/useradd -u 1000 user && chmod 711 / 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:dcbec58c730d25677dcfe2388b2e9f7163a41bf7e43c2a83d260a433dfe7e235 0.0s
=> => naming to docker.io/library/cdk-4ad30903e9dc3cf0d101b416f122ed20ea3382f34335268224dcfa79a193839b 0.0s
View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/saezj5py3h3t7qa3915d5kbas
What's Next?
View a summary of image vulnerabilities and recommendations → docker scout quickview
[+] Building 0.3s (14/14) FINISHED docker:desktop-linux
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.34kB 0.0s
=> [internal] load metadata for public.ecr.aws/sam/build-nodejs16.x:latest 0.2s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [ 1/10] FROM public.ecr.aws/sam/build-nodejs16.x:latest@sha256:7f3571a92b71470bfa4e73348c3ce61cd513a4a8b43b0fc17e46cb1203afcde1 0.0s
=> CACHED [ 2/10] RUN npm install --global yarn@1.22.5 0.0s
=> CACHED [ 3/10] RUN npm install --global pnpm@7.30.5 0.0s
=> CACHED [ 4/10] RUN npm install --global typescript 0.0s
=> CACHED [ 5/10] RUN npm install --global --unsafe-perm=true esbuild@0 0.0s
=> CACHED [ 6/10] RUN mkdir /tmp/npm-cache && chmod -R 777 /tmp/npm-cache && npm config --global set cache /tmp/npm-cache 0.0s
=> CACHED [ 7/10] RUN mkdir /tmp/yarn-cache && chmod -R 777 /tmp/yarn-cache && yarn config set cache-folder /tmp/yarn-cache 0.0s
=> CACHED [ 8/10] RUN mkdir /tmp/pnpm-cache && chmod -R 777 /tmp/pnpm-cache && pnpm config --global set store-dir /tmp/pnpm-cache 0.0s
=> CACHED [ 9/10] RUN npm config --global set update-notifier false 0.0s
=> CACHED [10/10] RUN /sbin/useradd -u 1000 user && chmod 711 / 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:dcbec58c730d25677dcfe2388b2e9f7163a41bf7e43c2a83d260a433dfe7e235 0.0s
=> => naming to docker.io/library/cdk-4ad30903e9dc3cf0d101b416f122ed20ea3382f34335268224dcfa79a193839b 0.0s
View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/0j1wk60s2tlz2nbpzyamv18ge
What's Next?
View a summary of image vulnerabilities and recommendations → docker scout quickview
[WARNING] aws-cdk-lib.aws_rds.DatabaseClusterProps#instanceProps is deprecated.
- use writer and readers instead
This API will be removed in the next major release.
[WARNING] aws-cdk-lib.aws_rds.DatabaseClusterProps#instances is deprecated.
- use writer and readers instead
This API will be removed in the next major release.
[+] Building 0.4s (14/14) FINISHED docker:desktop-linux
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.34kB 0.0s
=> [internal] load metadata for public.ecr.aws/sam/build-nodejs16.x:latest 0.3s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [ 1/10] FROM public.ecr.aws/sam/build-nodejs16.x:latest@sha256:7f3571a92b71470bfa4e73348c3ce61cd513a4a8b43b0fc17e46cb1203afcde1 0.0s
=> CACHED [ 2/10] RUN npm install --global yarn@1.22.5 0.0s
=> CACHED [ 3/10] RUN npm install --global pnpm@7.30.5 0.0s
=> CACHED [ 4/10] RUN npm install --global typescript 0.0s
=> CACHED [ 5/10] RUN npm install --global --unsafe-perm=true esbuild@0 0.0s
=> CACHED [ 6/10] RUN mkdir /tmp/npm-cache && chmod -R 777 /tmp/npm-cache && npm config --global set cache /tmp/npm-cache 0.0s
=> CACHED [ 7/10] RUN mkdir /tmp/yarn-cache && chmod -R 777 /tmp/yarn-cache && yarn config set cache-folder /tmp/yarn-cache 0.0s
=> CACHED [ 8/10] RUN mkdir /tmp/pnpm-cache && chmod -R 777 /tmp/pnpm-cache && pnpm config --global set store-dir /tmp/pnpm-cache 0.0s
=> CACHED [ 9/10] RUN npm config --global set update-notifier false 0.0s
=> CACHED [10/10] RUN /sbin/useradd -u 1000 user && chmod 711 / 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:dcbec58c730d25677dcfe2388b2e9f7163a41bf7e43c2a83d260a433dfe7e235 0.0s
=> => naming to docker.io/library/cdk-4ad30903e9dc3cf0d101b416f122ed20ea3382f34335268224dcfa79a193839b 0.0s
View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/bdpuqcr1i0voqtt2hzgvlpv5h
What's Next?
View a summary of image vulnerabilities and recommendations → docker scout quickview
[+] Building 0.3s (14/14) FINISHED docker:desktop-linux
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.34kB 0.0s
=> [internal] load metadata for public.ecr.aws/sam/build-nodejs16.x:latest 0.2s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [ 1/10] FROM public.ecr.aws/sam/build-nodejs16.x:latest@sha256:7f3571a92b71470bfa4e73348c3ce61cd513a4a8b43b0fc17e46cb1203afcde1 0.0s
=> CACHED [ 2/10] RUN npm install --global yarn@1.22.5 0.0s
=> CACHED [ 3/10] RUN npm install --global pnpm@7.30.5 0.0s
=> CACHED [ 4/10] RUN npm install --global typescript 0.0s
=> CACHED [ 5/10] RUN npm install --global --unsafe-perm=true esbuild@0 0.0s
=> CACHED [ 6/10] RUN mkdir /tmp/npm-cache && chmod -R 777 /tmp/npm-cache && npm config --global set cache /tmp/npm-cache 0.0s
=> CACHED [ 7/10] RUN mkdir /tmp/yarn-cache && chmod -R 777 /tmp/yarn-cache && yarn config set cache-folder /tmp/yarn-cache 0.0s
=> CACHED [ 8/10] RUN mkdir /tmp/pnpm-cache && chmod -R 777 /tmp/pnpm-cache && pnpm config --global set store-dir /tmp/pnpm-cache 0.0s
=> CACHED [ 9/10] RUN npm config --global set update-notifier false 0.0s
=> CACHED [10/10] RUN /sbin/useradd -u 1000 user && chmod 711 / 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:dcbec58c730d25677dcfe2388b2e9f7163a41bf7e43c2a83d260a433dfe7e235 0.0s
=> => naming to docker.io/library/cdk-4ad30903e9dc3cf0d101b416f122ed20ea3382f34335268224dcfa79a193839b 0.0s
View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/2pfxjr3i57jgofyvycg2wuiv7
What's Next?
View a summary of image vulnerabilities and recommendations → docker scout quickview
⏳ Bootstrapping environment aws://767398053083/sa-east-1...
Trusted accounts for deployment: (none)
Trusted accounts for lookup: (none)
Using default execution policy of 'arn:aws:iam::aws:policy/AdministratorAccess'. Pass '--cloudformation-execution-policies' to customize.
✨ hotswap deployment skipped - no changes were detected (use --force to override)
✅ Environment aws://767398053083/sa-east-1 bootstrapped (no changes).
Damians-MBP% cdk synth --profile villamora
[WARNING] aws-cdk-lib.aws_rds.DatabaseClusterProps#instanceProps is deprecated.
- use writer and readers instead
This API will be removed in the next major release.
[WARNING] aws-cdk-lib.aws_rds.DatabaseClusterProps#instances is deprecated.
- use writer and readers instead
This API will be removed in the next major release.
[+] Building 0.4s (14/14) FINISHED docker:desktop-linux
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.34kB 0.0s
=> [internal] load metadata for public.ecr.aws/sam/build-nodejs16.x:latest 0.3s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [ 1/10] FROM public.ecr.aws/sam/build-nodejs16.x:latest@sha256:7f3571a92b71470bfa4e73348c3ce61cd513a4a8b43b0fc17e46cb1203afcde1 0.0s
=> CACHED [ 2/10] RUN npm install --global yarn@1.22.5 0.0s
=> CACHED [ 3/10] RUN npm install --global pnpm@7.30.5 0.0s
=> CACHED [ 4/10] RUN npm install --global typescript 0.0s
=> CACHED [ 5/10] RUN npm install --global --unsafe-perm=true esbuild@0 0.0s
=> CACHED [ 6/10] RUN mkdir /tmp/npm-cache && chmod -R 777 /tmp/npm-cache && npm config --global set cache /tmp/npm-cache 0.0s
=> CACHED [ 7/10] RUN mkdir /tmp/yarn-cache && chmod -R 777 /tmp/yarn-cache && yarn config set cache-folder /tmp/yarn-cache 0.0s
=> CACHED [ 8/10] RUN mkdir /tmp/pnpm-cache && chmod -R 777 /tmp/pnpm-cache && pnpm config --global set store-dir /tmp/pnpm-cache 0.0s
=> CACHED [ 9/10] RUN npm config --global set update-notifier false 0.0s
=> CACHED [10/10] RUN /sbin/useradd -u 1000 user && chmod 711 / 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:dcbec58c730d25677dcfe2388b2e9f7163a41bf7e43c2a83d260a433dfe7e235 0.0s
=> => naming to docker.io/library/cdk-4ad30903e9dc3cf0d101b416f122ed20ea3382f34335268224dcfa79a193839b 0.0s
View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/grtrajx91i6jpsh07xp7fve1k
What's Next?
View a summary of image vulnerabilities and recommendations → docker scout quickview
Bundling asset atlas-development-application-layer/atlas-development-aurora-database/atlas-development-aurora-database-lambda-database-migration/atlas-development-migration/Code/Stage...
esbuild cannot run locally. Switching to Docker bundling.
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
cp: cannot stat ‘/asset-input/src/common/config/certs/rds-ca-2019-root.pem’: No such file or directory
/Users/damiancastellilluch/Documents/work/nestjs-boilerplate/node_modules/aws-cdk-lib/core/lib/asset-staging.js:2
`),localBundling=options.local?.tryBundle(bundleDir,options),!localBundling){const assetStagingOptions={sourcePath:this.sourcePath,bundleDir,...options};switch(options.bundlingFileAccess){case bundling_1().BundlingFileAccess.VOLUME_COPY:new(asset_staging_1()).AssetBundlingVolumeCopy(assetStagingOptions).run();break;case bundling_1().BundlingFileAccess.BIND_MOUNT:default:new(asset_staging_1()).AssetBundlingBindMount(assetStagingOptions).run();break}}}catch(err){const bundleErrorDir=bundleDir+"-error";throw fs().existsSync(bundleErrorDir)&&fs().removeSync(bundleErrorDir),fs().renameSync(bundleDir,bundleErrorDir),new Error(`Failed to bundle asset ${this.node.path}, bundle output is located at ${bundleErrorDir}: ${err}`)}if(fs_1().FileSystem.isEmpty(bundleDir)){const outputDir=localBundling?bundleDir:AssetStaging.BUNDLING_OUTPUT_DIR;throw new Error(`Bundling did not produce any output. Check that content is written to ${outputDir}.`)}}calculateHash(hashType,bundling,outputDir){if(hashType==assets_1().AssetHashType.CUSTOM||hashType==assets_1().AssetHashType.SOURCE&&bundling){const hash=crypto().createHash("sha256");return hash.update(this.customSourceFingerprint??fs_1().FileSystem.fingerprint(this.sourcePath,this.fingerprintOptions)),bundling&&hash.update(JSON.stringify(bundling,sanitizeHashValue)),hash.digest("hex")}switch(hashType){case assets_1().AssetHashType.SOURCE:return fs_1().FileSystem.fingerprint(this.sourcePath,this.fingerprintOptions);case assets_1().AssetHashType.BUNDLE:case assets_1().AssetHashType.OUTPUT:if(!outputDir)throw new Error(`Cannot use \`${hashType}\` hash type when \`bundling\` is not specified.`);return fs_1().FileSystem.fingerprint(outputDir,this.fingerprintOptions);default:throw new Error("Unknown asset hash type.")}}}exports.AssetStaging=AssetStaging,_a=JSII_RTTI_SYMBOL_1,AssetStaging[_a]={fqn:"aws-cdk-lib.AssetStaging",version:"2.138.0"},AssetStaging.BUNDLING_INPUT_DIR="/asset-input",AssetStaging.BUNDLING_OUTPUT_DIR="/asset-output",AssetStaging.assetCache=new(cache_1()).Cache;function renderAssetFilename(assetHash,extension=""){return`asset.${assetHash}${extension}`}function determineHashType(assetHashType,customSourceFingerprint){const hashType=customSourceFingerprint?assetHashType??assets_1().AssetHashType.CUSTOM:assetHashType??assets_1().AssetHashType.SOURCE;if(customSourceFingerprint&&hashType!==assets_1().AssetHashType.CUSTOM)throw new Error(`Cannot specify \`${assetHashType}\` for \`assetHashType\` when \`assetHash\` is specified. Use \`CUSTOM\` or leave \`undefined\`.`);if(hashType===assets_1().AssetHashType.CUSTOM&&!customSourceFingerprint)throw new Error("`assetHash` must be specified when `assetHashType` is set to `AssetHashType.CUSTOM`.");return hashType}function calculateCacheKey(props){return crypto().createHash("sha256").update(JSON.stringify(sortObject(props),sanitizeHashValue)).digest("hex")}function sortObject(object){if(typeof object!="object"||object instanceof Array)return object;const ret={};for(const key of Object.keys(object).sort())ret[key]=sortObject(object[key]);return ret}function sanitizeHashValue(key,value){if(key==="PIP_INDEX_URL"||key==="PIP_EXTRA_INDEX_URL")try{let url=new URL(value);if(url.password)return url.password="",url.toString()}catch(e){throw e.name==="TypeError"?new Error(`${key} must be a valid URL, got ${value}.`):e}return value}function findSingleFile(directory,archiveOnly){if(!fs().existsSync(directory))throw new Error(`Directory ${directory} does not exist.`);if(!fs().statSync(directory).isDirectory())throw new Error(`${directory} is not a directory.`);const content=fs().readdirSync(directory);if(content.length===1){const file=path().join(directory,content[0]),extension=getExtension(content[0]).toLowerCase();if(fs().statSync(file).isFile()&&(!archiveOnly||ARCHIVE_EXTENSIONS.includes(extension)))return file}}function determineBundledAsset(bundleDir,outputType){const archiveFile=findSingleFile(bundleDir,outputType!==bundling_1().BundlingOutput.SINGLE_FILE);switch(outputType===bundling_1().BundlingOutput.AUTO_DISCOVER&&(outputType=archiveFile?bundling_1().BundlingOutput.ARCHIVED:bundling_1().BundlingOutput.NOT_ARCHIVED),outputType){case bundling_1().BundlingOutput.NOT_ARCHIVED:return{path:bundleDir,packaging:assets_1().FileAssetPackaging.ZIP_DIRECTORY};case bundling_1().BundlingOutput.ARCHIVED:case bundling_1().BundlingOutput.SINGLE_FILE:if(!archiveFile)throw new Error("Bundling output directory is expected to include only a single file when `output` is set to `ARCHIVED` or `SINGLE_FILE`");return{path:archiveFile,packaging:assets_1().FileAssetPackaging.FILE,extension:getExtension(archiveFile)}}}function getExtension(source){for(const ext of ARCHIVE_EXTENSIONS)if(source.toLowerCase().endsWith(ext))return ext;return path().extname(source)}
^
Error: Failed to bundle asset atlas-development-application-layer/atlas-development-aurora-database/atlas-development-aurora-database-lambda-database-migration/atlas-development-migration/Code/Stage, bundle output is located at /Users/damiancastellilluch/Documents/work/nestjs-boilerplate/cdk.out/bundling-temp-51cb231e72cb54d3124369b2012c64bf375a5c12e10574845e42ea32f8a60c55-error: Error: docker exited with status 1
--> Command: docker run --rm -u "501:20" -v "/Users/damiancastellilluch/Documents/work/nestjs-boilerplate:/asset-input:delegated" -v "/Users/damiancastellilluch/Documents/work/nestjs-boilerplate/cdk.out/bundling-temp-51cb231e72cb54d3124369b2012c64bf375a5c12e10574845e42ea32f8a60c55:/asset-output:delegated" -w "/" cdk-4ad30903e9dc3cf0d101b416f122ed20ea3382f34335268224dcfa79a193839b bash -c "cp -R /asset-input/dist /asset-output/dist && cp /asset-input/tsconfig.json /asset-output/tsconfig.json && mkdir /asset-output/cert && cp -R /asset-input/src/common/config/certs/rds-ca-2019-root.pem /asset-output/cert && esbuild --bundle \"/asset-input/node_modules/@atlas-org/database/index.js\" --target=node16 --platform=node --outfile=\"/asset-output/index.js\" --external:aws-sdk --external:typeorm --external:ts-node --external:@nestjs/config --external:pg && echo '{\"dependencies\":{\"typeorm\":\"*\",\"ts-node\":\"10.9.2\",\"@nestjs/config\":\"3.2.2\",\"pg\":\"8.11.5\"}}' > \"/asset-output/package.json\" && cp \"/asset-input/package-lock.json\" \"/asset-output/package-lock.json\" && cd \"/asset-output\" && npm ci"
at AssetStaging.bundle (/Users/damiancastellilluch/Documents/work/nestjs-boilerplate/node_modules/aws-cdk-lib/core/lib/asset-staging.js:2:619)
at AssetStaging.stageByBundling (/Users/damiancastellilluch/Documents/work/nestjs-boilerplate/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:5297)
at stageThisAsset (/Users/damiancastellilluch/Documents/work/nestjs-boilerplate/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:2728)
at Cache.obtain (/Users/damiancastellilluch/Documents/work/nestjs-boilerplate/node_modules/aws-cdk-lib/core/lib/private/cache.js:1:242)
at new AssetStaging (/Users/damiancastellilluch/Documents/work/nestjs-boilerplate/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:3125)
at new Asset (/Users/damiancastellilluch/Documents/work/nestjs-boilerplate/node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.js:1:1141)
at AssetCode.bind (/Users/damiancastellilluch/Documents/work/nestjs-boilerplate/node_modules/aws-cdk-lib/aws-lambda/lib/code.js:1:4881)
at new Function (/Users/damiancastellilluch/Documents/work/nestjs-boilerplate/node_modules/aws-cdk-lib/aws-lambda/lib/function.js:1:9603)
at new NodejsFunction (/Users/damiancastellilluch/Documents/work/nestjs-boilerplate/node_modules/aws-cdk-lib/aws-lambda-nodejs/lib/function.js:1:1669)
at new LambdaDatabaseMigration (/Users/damiancastellilluch/Documents/work/nestjs-boilerplate/dist/infra/constructs/lambda-database-migration/lambda-database-migration.construct.js:30:31)
Node.js v18.15.0
Subprocess exited with error 1
Damians-MBP%
First I ran cdk bootstrap
-> OK
My bad Damian, I didn't add the rds certificate file, in a few minutes @junior-anzolin will fix.
The change is already on repository, @douglasgc can you please review the Pull Request https://github.com/atlas-cli/nestjs-boilerplate/pull/22?
Thank you @junior-anzolin. merged.
Same error
[WARNING] aws-cdk-lib.aws_rds.DatabaseClusterProps#instanceProps is deprecated.
- use writer and readers instead
This API will be removed in the next major release.
[WARNING] aws-cdk-lib.aws_rds.DatabaseClusterProps#instances is deprecated.
- use writer and readers instead
This API will be removed in the next major release.
[+] Building 0.4s (14/14) FINISHED docker:desktop-linux
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.34kB 0.0s
=> [internal] load metadata for public.ecr.aws/sam/build-nodejs16.x:latest 0.3s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [ 1/10] FROM public.ecr.aws/sam/build-nodejs16.x:latest@sha256:7f3571a92b71470bfa4e73348c3ce61cd513a4a8b43b0fc17e46cb1203afcde1 0.0s
=> CACHED [ 2/10] RUN npm install --global yarn@1.22.5 0.0s
=> CACHED [ 3/10] RUN npm install --global pnpm@7.30.5 0.0s
=> CACHED [ 4/10] RUN npm install --global typescript 0.0s
=> CACHED [ 5/10] RUN npm install --global --unsafe-perm=true esbuild@0 0.0s
=> CACHED [ 6/10] RUN mkdir /tmp/npm-cache && chmod -R 777 /tmp/npm-cache && npm config --global set cache /tmp/npm-cache 0.0s
=> CACHED [ 7/10] RUN mkdir /tmp/yarn-cache && chmod -R 777 /tmp/yarn-cache && yarn config set cache-folder /tmp/yarn-cache 0.0s
=> CACHED [ 8/10] RUN mkdir /tmp/pnpm-cache && chmod -R 777 /tmp/pnpm-cache && pnpm config --global set store-dir /tmp/pnpm-cache 0.0s
=> CACHED [ 9/10] RUN npm config --global set update-notifier false 0.0s
=> CACHED [10/10] RUN /sbin/useradd -u 1000 user && chmod 711 / 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:dcbec58c730d25677dcfe2388b2e9f7163a41bf7e43c2a83d260a433dfe7e235 0.0s
=> => naming to docker.io/library/cdk-4ad30903e9dc3cf0d101b416f122ed20ea3382f34335268224dcfa79a193839b 0.0s
View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/9a8drw6nktn4jcyodi99oj13f
What's Next?
View a summary of image vulnerabilities and recommendations → docker scout quickview
Bundling asset atlas-development-application-layer/atlas-development-aurora-database/atlas-development-aurora-database-lambda-database-migration/atlas-development-migration/Code/Stage...
esbuild cannot run locally. Switching to Docker bundling.
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
cp: cannot stat ‘/asset-input/src/common/config/certs/rds-ca-2019-root.pem’: No such file or directory
/Users/damiancastellilluch/Documents/work/nestjs-boilerplate/node_modules/aws-cdk-lib/core/lib/asset-staging.js:2
`),localBundling=options.local?.tryBundle(bundleDir,options),!localBundling){const assetStagingOptions={sourcePath:this.sourcePath,bundleDir,...options};switch(options.bundlingFileAccess){case bundling_1().BundlingFileAccess.VOLUME_COPY:new(asset_staging_1()).AssetBundlingVolumeCopy(assetStagingOptions).run();break;case bundling_1().BundlingFileAccess.BIND_MOUNT:default:new(asset_staging_1()).AssetBundlingBindMount(assetStagingOptions).run();break}}}catch(err){const bundleErrorDir=bundleDir+"-error";throw fs().existsSync(bundleErrorDir)&&fs().removeSync(bundleErrorDir),fs().renameSync(bundleDir,bundleErrorDir),new Error(`Failed to bundle asset ${this.node.path}, bundle output is located at ${bundleErrorDir}: ${err}`)}if(fs_1().FileSystem.isEmpty(bundleDir)){const outputDir=localBundling?bundleDir:AssetStaging.BUNDLING_OUTPUT_DIR;throw new Error(`Bundling did not produce any output. Check that content is written to ${outputDir}.`)}}calculateHash(hashType,bundling,outputDir){if(hashType==assets_1().AssetHashType.CUSTOM||hashType==assets_1().AssetHashType.SOURCE&&bundling){const hash=crypto().createHash("sha256");return hash.update(this.customSourceFingerprint??fs_1().FileSystem.fingerprint(this.sourcePath,this.fingerprintOptions)),bundling&&hash.update(JSON.stringify(bundling,sanitizeHashValue)),hash.digest("hex")}switch(hashType){case assets_1().AssetHashType.SOURCE:return fs_1().FileSystem.fingerprint(this.sourcePath,this.fingerprintOptions);case assets_1().AssetHashType.BUNDLE:case assets_1().AssetHashType.OUTPUT:if(!outputDir)throw new Error(`Cannot use \`${hashType}\` hash type when \`bundling\` is not specified.`);return fs_1().FileSystem.fingerprint(outputDir,this.fingerprintOptions);default:throw new Error("Unknown asset hash type.")}}}exports.AssetStaging=AssetStaging,_a=JSII_RTTI_SYMBOL_1,AssetStaging[_a]={fqn:"aws-cdk-lib.AssetStaging",version:"2.138.0"},AssetStaging.BUNDLING_INPUT_DIR="/asset-input",AssetStaging.BUNDLING_OUTPUT_DIR="/asset-output",AssetStaging.assetCache=new(cache_1()).Cache;function renderAssetFilename(assetHash,extension=""){return`asset.${assetHash}${extension}`}function determineHashType(assetHashType,customSourceFingerprint){const hashType=customSourceFingerprint?assetHashType??assets_1().AssetHashType.CUSTOM:assetHashType??assets_1().AssetHashType.SOURCE;if(customSourceFingerprint&&hashType!==assets_1().AssetHashType.CUSTOM)throw new Error(`Cannot specify \`${assetHashType}\` for \`assetHashType\` when \`assetHash\` is specified. Use \`CUSTOM\` or leave \`undefined\`.`);if(hashType===assets_1().AssetHashType.CUSTOM&&!customSourceFingerprint)throw new Error("`assetHash` must be specified when `assetHashType` is set to `AssetHashType.CUSTOM`.");return hashType}function calculateCacheKey(props){return crypto().createHash("sha256").update(JSON.stringify(sortObject(props),sanitizeHashValue)).digest("hex")}function sortObject(object){if(typeof object!="object"||object instanceof Array)return object;const ret={};for(const key of Object.keys(object).sort())ret[key]=sortObject(object[key]);return ret}function sanitizeHashValue(key,value){if(key==="PIP_INDEX_URL"||key==="PIP_EXTRA_INDEX_URL")try{let url=new URL(value);if(url.password)return url.password="",url.toString()}catch(e){throw e.name==="TypeError"?new Error(`${key} must be a valid URL, got ${value}.`):e}return value}function findSingleFile(directory,archiveOnly){if(!fs().existsSync(directory))throw new Error(`Directory ${directory} does not exist.`);if(!fs().statSync(directory).isDirectory())throw new Error(`${directory} is not a directory.`);const content=fs().readdirSync(directory);if(content.length===1){const file=path().join(directory,content[0]),extension=getExtension(content[0]).toLowerCase();if(fs().statSync(file).isFile()&&(!archiveOnly||ARCHIVE_EXTENSIONS.includes(extension)))return file}}function determineBundledAsset(bundleDir,outputType){const archiveFile=findSingleFile(bundleDir,outputType!==bundling_1().BundlingOutput.SINGLE_FILE);switch(outputType===bundling_1().BundlingOutput.AUTO_DISCOVER&&(outputType=archiveFile?bundling_1().BundlingOutput.ARCHIVED:bundling_1().BundlingOutput.NOT_ARCHIVED),outputType){case bundling_1().BundlingOutput.NOT_ARCHIVED:return{path:bundleDir,packaging:assets_1().FileAssetPackaging.ZIP_DIRECTORY};case bundling_1().BundlingOutput.ARCHIVED:case bundling_1().BundlingOutput.SINGLE_FILE:if(!archiveFile)throw new Error("Bundling output directory is expected to include only a single file when `output` is set to `ARCHIVED` or `SINGLE_FILE`");return{path:archiveFile,packaging:assets_1().FileAssetPackaging.FILE,extension:getExtension(archiveFile)}}}function getExtension(source){for(const ext of ARCHIVE_EXTENSIONS)if(source.toLowerCase().endsWith(ext))return ext;return path().extname(source)}
^
Error: Failed to bundle asset atlas-development-application-layer/atlas-development-aurora-database/atlas-development-aurora-database-lambda-database-migration/atlas-development-migration/Code/Stage, bundle output is located at /Users/damiancastellilluch/Documents/work/nestjs-boilerplate/cdk.out/bundling-temp-51cb231e72cb54d3124369b2012c64bf375a5c12e10574845e42ea32f8a60c55-error: Error: docker exited with status 1
--> Command: docker run --rm -u "501:20" -v "/Users/damiancastellilluch/Documents/work/nestjs-boilerplate:/asset-input:delegated" -v "/Users/damiancastellilluch/Documents/work/nestjs-boilerplate/cdk.out/bundling-temp-51cb231e72cb54d3124369b2012c64bf375a5c12e10574845e42ea32f8a60c55:/asset-output:delegated" -w "/" cdk-4ad30903e9dc3cf0d101b416f122ed20ea3382f34335268224dcfa79a193839b bash -c "cp -R /asset-input/dist /asset-output/dist && cp /asset-input/tsconfig.json /asset-output/tsconfig.json && mkdir /asset-output/cert && cp -R /asset-input/src/common/config/certs/rds-ca-2019-root.pem /asset-output/cert && esbuild --bundle \"/asset-input/node_modules/@atlas-org/database/index.js\" --target=node16 --platform=node --outfile=\"/asset-output/index.js\" --external:aws-sdk --external:typeorm --external:ts-node --external:@nestjs/config --external:pg && echo '{\"dependencies\":{\"typeorm\":\"*\",\"ts-node\":\"10.9.2\",\"@nestjs/config\":\"3.2.2\",\"pg\":\"8.11.5\"}}' > \"/asset-output/package.json\" && cp \"/asset-input/package-lock.json\" \"/asset-output/package-lock.json\" && cd \"/asset-output\" && npm ci"
at AssetStaging.bundle (/Users/damiancastellilluch/Documents/work/nestjs-boilerplate/node_modules/aws-cdk-lib/core/lib/asset-staging.js:2:619)
at AssetStaging.stageByBundling (/Users/damiancastellilluch/Documents/work/nestjs-boilerplate/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:5297)
at stageThisAsset (/Users/damiancastellilluch/Documents/work/nestjs-boilerplate/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:2728)
at Cache.obtain (/Users/damiancastellilluch/Documents/work/nestjs-boilerplate/node_modules/aws-cdk-lib/core/lib/private/cache.js:1:242)
at new AssetStaging (/Users/damiancastellilluch/Documents/work/nestjs-boilerplate/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:3125)
at new Asset (/Users/damiancastellilluch/Documents/work/nestjs-boilerplate/node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.js:1:1141)
at AssetCode.bind (/Users/damiancastellilluch/Documents/work/nestjs-boilerplate/node_modules/aws-cdk-lib/aws-lambda/lib/code.js:1:4881)
at new Function (/Users/damiancastellilluch/Documents/work/nestjs-boilerplate/node_modules/aws-cdk-lib/aws-lambda/lib/function.js:1:9603)
at new NodejsFunction (/Users/damiancastellilluch/Documents/work/nestjs-boilerplate/node_modules/aws-cdk-lib/aws-lambda-nodejs/lib/function.js:1:1669)
at new LambdaDatabaseMigration (/Users/damiancastellilluch/Documents/work/nestjs-boilerplate/dist/infra/constructs/lambda-database-migration/lambda-database-migration.construct.js:30:31)
Node.js v18.15.0
Subprocess exited with error 1
Damians-MBP%
with cdk deploy
On local, it seems that I had no problems, at least NestJS starts fine.
cp: cannot stat ‘/asset-input/src/common/config/certs/rds-ca-2019-root.pem’: No such file or directory
I looked for this expression in the code and couldn't find it.
Are you sure you pull the master and run:
npm run build && npm run build:infra && cdk ...
This has been left unparameterized.
We don't have documentation on this yet.
However, in the infrastructure section, we don't use the .env file; it's only for the application environment (backend).
In the infrastructure section, environment variables are defined in the code. This was our initial decision, and while we're considering improvements for future versions, it currently serves its purpose well.
Therefore, you need to update the following files with your account information:
infra/index.ts /infra/constructs/lambda-nestjs-function/constants.ts
In the file '/infra/constructs/lambda-nestjs-function/constants.ts', we have the backend environment settings running on the lambda server. You should also update this file. However, please note that the database settings are already configured automatically; you don't need to add them.
I have just seen the files, and they are parameters that are a bit confusing, I think the best (opinion) is that they take out as much as possible, because if not, you have to go investigating where each parameter goes, what it is for, there are too many.
We agree with you, and it is also very important to explain each of the parameters and improve our documentation. In addition to improving the organization and where these settings.
We also recorded a video here explaining the repository and how to deploy it, but we will still review and edit it for posting.
The project, if they simplify it as much as possible, looks very good. I have tried several options and it is the best. It can have a good reach
Let me know when you have something? I'm interested for a project I'm starting, and I've already done something with CDK. But your project is very good for me to have a base. I have doubts about what I have to complete in these files that you indicate.
What should I fill in here besides the AWS account and the zone? Where do I get the other parameters from?
const infraestructure = new AtlasInfraestructure({
production: {
// Name of your application
applicationName: 'atlas',
// Stage name for the environment
stageName: 'production',
// Domain name environment
domainName: 'sandbox.slingui.com',
// API domain name for the environment
apiDomainName: 'api.sandbox.slingui.com',
// Public host ID for the environment (AWS Route 53 Hosted Zone ID)
idPublicHostZone: 'Z01545163ANT5OQYS99UY',
env: {
// AWS account ID for the environment
account: '767397837500',
// AWS region for the environment (e.g., 'us-east-1')
region: 'us-east-1',
},
layersStack: createStacks(),
},
development: {
// Name of your application
applicationName: 'atlas',
// Stage name for the environment
stageName: 'development',
// Domain name environment
domainName: 'sandbox.slingui.com',
// API domain name for the environment
apiDomainName: 'api.sandbox.slingui.com',
// Public host zone ID for the environment (AWS Route 53 Hosted Zone ID)
idPublicHostZone: 'Z01545163ANT5OQYS99UY',
env: {
// AWS account ID for the environment
account: '767397837500',
// AWS region for the environment (e.g., 'us-east-1')
region: 'us-east-1',
},
layersStack: createStacks(),
},
});
And what should I change in this file?
Thanks!
import * as cdk from 'aws-cdk-lib';
import { Duration } from 'aws-cdk-lib';
import { Runtime } from 'aws-cdk-lib/aws-lambda';
import { join } from 'path';
// Import ignore packages NODE_EXTERNALS
export const DEFAULT_NESTJS_NODE_EXTERNALS = [
'kafkajs',
'mqtt',
'amqplib',
'amqp-connection-manager',
'ioredis',
'redis',
'nats',
'@grpc/grpc-js',
'@grpc/proto-loader',
'@nestjs/websockets/socket-module',
'@nestjs/microservices',
'@nestjs/microservices/microservices-module',
'class-transformer/storage',
'pg-native',
'hbs',
'nestjs-redoc',
'cache-manager',
'fsevents',
'fastify-swagger',
'swagger-ui-express',
'typescript',
'@nestjs/cli',
];
export const NESTJS_SWAGGER_MODULES = ['oidc-provider', 'swagger-ui-express', '@nestjs/swagger', '@babel/plugin-proposal-export-namespace-from', '@babel/plugin-transform-modules-commonjs'];
export const DEFAULT_NESTJS_NODE_MODULE = ['oidc-provider', '@babel/plugin-proposal-export-namespace-from', '@babel/plugin-transform-modules-commonjs'];
export const DEFAULT_NESTJS_COMMAND_HOOKS = {
beforeBundling: (inputDir: string, outputDir: string): string[] => {
return [
`mkdir ${outputDir}/cert`,
`cp -R ${inputDir}/src/common/config/certs/rds-combined-ca-bundle.pem ${outputDir}/cert`,
`mkdir ${outputDir}/templates`,
//`cp -R ${inputDir}/src/common/mail/templates/* ${outputDir}/templates`,
`mkdir ${outputDir}/i18n`,
`cp -R ${inputDir}/src/i18n/* ${outputDir}/i18n`,
];
},
afterBundling: (): string[] => [],
beforeInstall: (): string[] => [],
};
export const DEFAULT_NESTJS_FUNCTION_PROPS = {
depsLockFilePath: join(
__dirname,
'..',
'..',
'..',
'..',
'package-lock.json',
),
memorySize: 2048,
timeout: Duration.seconds(6),
runtime: Runtime.NODEJS_20_X,
allowPublicSubnet: true,
bundling: {
minify: true,
keepNames: true,
sourcemap: true,
zip: true,
externalModules: DEFAULT_NESTJS_NODE_EXTERNALS,
nodeModules: DEFAULT_NESTJS_NODE_MODULE,
commandHooks: DEFAULT_NESTJS_COMMAND_HOOKS,
},
};
export const DEFAULT_NESTJS_LAMBDA_ENVIRONMENT = {
production: {
NODE_ENV: 'production',
APP_PORT: '3000',
APP_NAME: 'NestJS Boilerplate',
APP_FALLBACK_LANGUAGE: 'en',
APP_HEADER_LANGUAGE: 'x-custom-lang',
FRONTEND_DOMAIN: 'https://localhost:4200',
BACKEND_DOMAIN: 'https://api.yourdomain.com',
SWAGGER_ENABLED: 'true',
I18N_DIRECTORY: 'i18n',
AUTH_JWT_SECRET: 'put-your-secret-here',
AUTH_JWT_TOKEN_EXPIRES_IN: '1d',
SESSIONS_TABLE_NAME: 'atlas-production-sessions',
MAIL_TEMPLATES_PATH: 'templates',
MAIL_FROM: 'info@yourdomain.com.br',
AWS_STORAGE_CREDENTIAL: 'profile',
AWS_STORAGE_REGION: 'us-east-1',
},
development: {
// App
NODE_ENV: 'development',
APP_PORT: '3000',
APP_NAME: 'NestJS Boilerplate',
APP_FALLBACK_LANGUAGE: 'en',
APP_HEADER_LANGUAGE: 'x-custom-lang',
FRONTEND_DOMAIN: 'https://localhost:4200',
BACKEND_DOMAIN: 'https://api.yourdomain.com',
SWAGGER_ENABLED: 'true',
I18N_DIRECTORY: 'i18n',
AUTH_JWT_SECRET: 'put-your-secret-here',
AUTH_JWT_TOKEN_EXPIRES_IN: '1d',
SESSIONS_TABLE_NAME: 'atlas-development-sessions',
MAIL_TEMPLATES_PATH: 'templates',
MAIL_FROM: 'info@yourdomain.com.br',
AWS_STORAGE_CREDENTIAL: 'profile',
AWS_STORAGE_REGION: 'us-east-1',
}
};
export const createDatabaseAuroraEnvironment = (name: string) => {
return {
DATABASE_TYPE: 'postgres',
DATABASE_HOST: cdk.Fn.importValue(name + '-proxy-host'),
DATABASE_USERNAME: 'postgres',
DATABASE_PORT: '5432',
DATABASE_NAME: 'postgres',
DATABASE_REJECT_UNAUTHORIZED: 'true',
DATABASE_SSL_ENABLED: 'true',
DATABASE_SYNCHRONIZE: 'false',
};
};
Hello @damianlluch, we are very happy with your feedback and how it can be useful for you. It has been very useful for our projects here at Atlas.
Our vision is that in fact this repository must still be polished, in order to allow the user to select what they want to use and configure through a CLI, and also to advance in the simplification and complete documentation of it (of all decisions and details) .
We are also thinking about creating a discord or something like that to facilitate communication and debugging for our community and we are also thinking about creating a consultancy model for our sponsors.
What should I fill in here besides the AWS account and the zone? Where do I get the other parameters from?
const infraestructure = new AtlasInfraestructure({ production: { // Name of your application applicationName: 'atlas', // Stage name for the environment stageName: 'production', // Domain name environment domainName: 'sandbox.slingui.com', // API domain name for the environment apiDomainName: 'api.sandbox.slingui.com', // Public host ID for the environment (AWS Route 53 Hosted Zone ID) idPublicHostZone: 'Z01545163ANT5OQYS99UY', env: { // AWS account ID for the environment account: '767397837500', // AWS region for the environment (e.g., 'us-east-1') region: 'us-east-1', }, layersStack: createStacks(), }, development: { // Name of your application applicationName: 'atlas', // Stage name for the environment stageName: 'development', // Domain name environment domainName: 'sandbox.slingui.com', // API domain name for the environment apiDomainName: 'api.sandbox.slingui.com', // Public host zone ID for the environment (AWS Route 53 Hosted Zone ID) idPublicHostZone: 'Z01545163ANT5OQYS99UY', env: { // AWS account ID for the environment account: '767397837500', // AWS region for the environment (e.g., 'us-east-1') region: 'us-east-1', }, layersStack: createStacks(), }, });
To start this repository on AWS, you need to have a Hosted Zone on Route53 on AWS, this is important because we generate all the necessary certificates and publish the records on the domain, as well as link all the APIs in a subdomain.domain.com.
Update the applicationName: Replace applicationName with your project name. This will affect the initial name of all resources created in AWS.
Stage name configuration: By default, the deployment will be done to the development environment. To change this, use the cdk deploy --context=environment=production command.
Get Hosted Zone data from Route53: domainName: This is the name of your Hosted Zone (e.g. development.slingui.com). idPublicHostZone: This is the ID of your Hosted Zone. (e.g. Z064220936GEXQT63QIQ4)
Select your AWS account and region: env.account: Your AWS account ID. region: The AWS region where you want to deploy.
You just need to worry about this part:
export const DEFAULT_NESTJS_LAMBDA_ENVIRONMENT = { production: { NODE_ENV: 'production', APP_PORT: '3000', APP_NAME: 'NestJS Boilerplate', APP_FALLBACK_LANGUAGE: 'en', APP_HEADER_LANGUAGE: 'x-custom-lang',
FRONTEND_DOMAIN: 'https://localhost:4200',
BACKEND_DOMAIN: 'https://api.yourdomain.com',
SWAGGER_ENABLED: 'true',
I18N_DIRECTORY: 'i18n',
AUTH_JWT_SECRET: 'put-your-secret-here',
AUTH_JWT_TOKEN_EXPIRES_IN: '1d',
SESSIONS_TABLE_NAME: 'atlas-production-sessions',
MAIL_TEMPLATES_PATH: 'templates',
MAIL_FROM: 'info@yourdomain.com.br',
AWS_STORAGE_CREDENTIAL: 'profile',
AWS_STORAGE_REGION: 'us-east-1',
}, development: { // App NODE_ENV: 'development', APP_PORT: '3000', APP_NAME: 'NestJS Boilerplate', APP_FALLBACK_LANGUAGE: 'en', APP_HEADER_LANGUAGE: 'x-custom-lang',
FRONTEND_DOMAIN: 'https://localhost:4200',
BACKEND_DOMAIN: 'https://api.yourdomain.com',
SWAGGER_ENABLED: 'true',
I18N_DIRECTORY: 'i18n',
AUTH_JWT_SECRET: 'put-your-secret-here',
AUTH_JWT_TOKEN_EXPIRES_IN: '1d',
SESSIONS_TABLE_NAME: 'atlas-development-sessions',
MAIL_TEMPLATES_PATH: 'templates',
MAIL_FROM: 'info@yourdomain.com.br',
AWS_STORAGE_CREDENTIAL: 'profile',
AWS_STORAGE_REGION: 'us-east-1',
} };
Most of these variables are from the NestJS standard itself.
You can deploy without changing anything, just the SESSIONS_TABLE_NAME field, it must always be in the format {applicationName}-{environment (development or production)}-sessions
please ignore or remove the AWS_STORAGE_CREDENTIAL AWS_STORAGE_REGION (They are for a future Storage module integrated with S3)
Change the BACKEND_DOMAIN to the same as your apiDomainName, 'api.' + $domainname
The rest you can only update if you want, but we recommend that you update APP_NAME and AUTH_JWT_SECRET.
To start this repository on AWS, you need to have a Hosted Zone on Route53 on AWS, this is important because we generate all the necessary certificates and publish the records on the domain, as well as link all the APIs in a subdomain.domain.com.
- Update the applicationName: Replace applicationName with your project name. This will affect the initial name of all resources created in AWS.
- Stage name configuration: By default, the deployment will be done to the development environment. To change this, use the cdk deploy --context=environment=production command.
- Get Hosted Zone data from Route53: domainName: This is the name of your Hosted Zone (e.g. development.slingui.com). idPublicHostZone: This is the ID of your Hosted Zone. (e.g. Z064220936GEXQT63QIQ4)
- Select your AWS account and region: env.account: Your AWS account ID. region: The AWS region where you want to deploy.
Sure, it's a bit confusing to me. Why do you have to play Route53 in this instance? I've deployed other projects with CDK, and that's something I do after the fact.
Most of these variables are from the NestJS standard itself.
You can deploy without changing anything, just the SESSIONS_TABLE_NAME field, it must always be in the format {applicationName}-{environment (development or production)}-sessions
please ignore or remove the AWS_STORAGE_CREDENTIAL AWS_STORAGE_REGION (They are for a future Storage module integrated with S3)
Change the BACKEND_DOMAIN to the same as your apiDomainName, 'api.' + $domainname
The rest you can only update if you want, but we recommend that you update APP_NAME and AUTH_JWT_SECRET.
I get the backend URL when I deploy the API Gateway. Why is it necessary in configuration a value that is obtained when deploying the API Gateway?
To start this repository on AWS, you need to have a Hosted Zone on Route53 on AWS, this is important because we generate all the necessary certificates and publish the records on the domain, as well as link all the APIs in a subdomain.domain.com.
- Update the applicationName: Replace applicationName with your project name. This will affect the initial name of all resources created in AWS.
- Stage name configuration: By default, the deployment will be done to the development environment. To change this, use the cdk deploy --context=environment=production command.
- Get Hosted Zone data from Route53: domainName: This is the name of your Hosted Zone (e.g. development.slingui.com). idPublicHostZone: This is the ID of your Hosted Zone. (e.g. Z064220936GEXQT63QIQ4)
- Select your AWS account and region: env.account: Your AWS account ID. region: The AWS region where you want to deploy.
Sure, it's a bit confusing to me. Why do you have to play Route53 in this instance? I've deployed other projects with CDK, and that's something I do after the fact.
I understand the decision to make route53 records later manually, after all some projects don't have a domain initially, but I really see a lot of value in creating SSL certificates for https as part of this repository, it really makes things a lot easier. (and in the future the user will be able to select whether or not) You can comment on these parts of the code, but I believe that would be a step backwards.
Most of these variables are from the NestJS standard itself. You can deploy without changing anything, just the SESSIONS_TABLE_NAME field, it must always be in the format {applicationName}-{environment (development or production)}-sessions please ignore or remove the AWS_STORAGE_CREDENTIAL AWS_STORAGE_REGION (They are for a future Storage module integrated with S3) Change the BACKEND_DOMAIN to the same as your apiDomainName, 'api.' + $domainname The rest you can only update if you want, but we recommend that you update APP_NAME and AUTH_JWT_SECRET.
I get the backend URL when I deploy the API Gateway. Why is it necessary in configuration a value that is obtained when deploying the API Gateway?
SESSIONS_TABLE_NAME
This can really be improved, and also SESSIONS_TABLE_NAME. I'll work on it.
Hi guys, I was trying to test with your project and I am getting this error.