@phila/cli 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/config.d.ts +30 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +135 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/deploy.d.ts +2 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +224 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/destroy.d.ts +3 -0
- package/dist/commands/destroy.d.ts.map +1 -0
- package/dist/commands/destroy.js +110 -0
- package/dist/commands/destroy.js.map +1 -0
- package/dist/commands/init.d.ts +25 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +513 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/map.d.ts +8 -0
- package/dist/commands/map.d.ts.map +1 -0
- package/dist/commands/map.js +186 -0
- package/dist/commands/map.js.map +1 -0
- package/dist/commands/ship.d.ts +20 -0
- package/dist/commands/ship.d.ts.map +1 -0
- package/dist/commands/ship.js +445 -0
- package/dist/commands/ship.js.map +1 -0
- package/dist/commands/templates.d.ts +3 -0
- package/dist/commands/templates.d.ts.map +1 -0
- package/dist/commands/templates.js +120 -0
- package/dist/commands/templates.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +82 -0
- package/dist/index.js.map +1 -0
- package/dist/templates/_shared/city.config.json.tmpl +24 -0
- package/dist/templates/_shared/dotnet-api/Api.csproj +17 -0
- package/dist/templates/_shared/dotnet-api/Program.cs +58 -0
- package/dist/templates/_shared/dotnet-api/aws-lambda-tools-defaults.json +10 -0
- package/dist/templates/_shared/dotnet-api/obj/Api.csproj.nuget.dgspec.json +80 -0
- package/dist/templates/_shared/dotnet-api/obj/Api.csproj.nuget.g.props +15 -0
- package/dist/templates/_shared/dotnet-api/obj/Api.csproj.nuget.g.targets +2 -0
- package/dist/templates/_shared/dotnet-api/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs +4 -0
- package/dist/templates/_shared/dotnet-api/obj/Debug/net8.0/Api.AssemblyInfo.cs +22 -0
- package/dist/templates/_shared/dotnet-api/obj/Debug/net8.0/Api.AssemblyInfoInputs.cache +1 -0
- package/dist/templates/_shared/dotnet-api/obj/Debug/net8.0/Api.GeneratedMSBuildEditorConfig.editorconfig +19 -0
- package/dist/templates/_shared/dotnet-api/obj/Debug/net8.0/Api.GlobalUsings.g.cs +17 -0
- package/dist/templates/_shared/dotnet-api/obj/Debug/net8.0/Api.assets.cache +0 -0
- package/dist/templates/_shared/dotnet-api/obj/Debug/net8.0/Api.csproj.AssemblyReference.cache +0 -0
- package/dist/templates/_shared/dotnet-api/obj/project.assets.json +708 -0
- package/dist/templates/_shared/dotnet-api/obj/project.nuget.cache +35 -0
- package/dist/templates/_shared/dotnet-api-postgres/Api.csproj +19 -0
- package/dist/templates/_shared/dotnet-api-postgres/Program.cs +167 -0
- package/dist/templates/_shared/dotnet-api-postgres/aws-lambda-tools-defaults.json +10 -0
- package/dist/templates/_shared/dotnet-api-postgres/obj/Api.csproj.nuget.dgspec.json +88 -0
- package/dist/templates/_shared/dotnet-api-postgres/obj/Api.csproj.nuget.g.props +15 -0
- package/dist/templates/_shared/dotnet-api-postgres/obj/Api.csproj.nuget.g.targets +2 -0
- package/dist/templates/_shared/dotnet-api-postgres/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs +4 -0
- package/dist/templates/_shared/dotnet-api-postgres/obj/Debug/net8.0/Api.AssemblyInfo.cs +22 -0
- package/dist/templates/_shared/dotnet-api-postgres/obj/Debug/net8.0/Api.AssemblyInfoInputs.cache +1 -0
- package/dist/templates/_shared/dotnet-api-postgres/obj/Debug/net8.0/Api.GeneratedMSBuildEditorConfig.editorconfig +19 -0
- package/dist/templates/_shared/dotnet-api-postgres/obj/Debug/net8.0/Api.GlobalUsings.g.cs +17 -0
- package/dist/templates/_shared/dotnet-api-postgres/obj/Debug/net8.0/Api.assets.cache +0 -0
- package/dist/templates/_shared/dotnet-api-postgres/obj/project.assets.json +106 -0
- package/dist/templates/_shared/dotnet-api-postgres/obj/project.nuget.cache +15 -0
- package/dist/templates/_shared/nuxt-frontend/app.vue +3 -0
- package/dist/templates/_shared/nuxt-frontend/nuxt.config.ts +25 -0
- package/dist/templates/_shared/nuxt-frontend/package.json.tmpl +19 -0
- package/dist/templates/_shared/nuxt-frontend/pages/index.vue +6 -0
- package/dist/templates/_shared/nuxt-frontend/public/.gitkeep +0 -0
- package/dist/templates/_shared/nuxt-frontend/tsconfig.json +3 -0
- package/dist/templates/_shared/webapp-cdk-package.json.tmpl +23 -0
- package/dist/templates/_shared/webapp-frontend/app.vue +3 -0
- package/dist/templates/_shared/webapp-frontend/nuxt.config.ts +25 -0
- package/dist/templates/_shared/webapp-frontend/package.json.tmpl +19 -0
- package/dist/templates/_shared/webapp-frontend/pages/index.vue +7 -0
- package/dist/templates/_shared/webapp-frontend/public/.gitkeep +0 -0
- package/dist/templates/_shared/webapp-frontend/tsconfig.json +3 -0
- package/dist/templates/lambda-api-nodejs/README.md.tmpl +203 -0
- package/dist/templates/lambda-api-nodejs/apps/__lambdaName__/index.ts +89 -0
- package/dist/templates/lambda-api-nodejs/apps/__lambdaName__/package.json +17 -0
- package/dist/templates/lambda-api-nodejs/apps/__lambdaName__/tsconfig.json +8 -0
- package/dist/templates/lambda-api-nodejs/cdk/app.ts.tmpl +53 -0
- package/dist/templates/lambda-api-nodejs/cdk/cdk.json +68 -0
- package/dist/templates/lambda-api-nodejs/cdk/package.json +23 -0
- package/dist/templates/lambda-api-nodejs/cdk/tsconfig.json +9 -0
- package/dist/templates/lambda-api-nodejs/package.json.tmpl +20 -0
- package/dist/templates/lambda-api-nodejs/tsconfig.json +27 -0
- package/dist/templates/lambda-dynamo-api/README.md.tmpl +184 -0
- package/dist/templates/lambda-dynamo-api/apps/__lambdaName__/index.ts +109 -0
- package/dist/templates/lambda-dynamo-api/apps/__lambdaName__/package.json +19 -0
- package/dist/templates/lambda-dynamo-api/apps/__lambdaName__/tsconfig.json +24 -0
- package/dist/templates/lambda-dynamo-api/cdk/app.ts.tmpl +59 -0
- package/dist/templates/lambda-dynamo-api/cdk/cdk.json +73 -0
- package/dist/templates/lambda-dynamo-api/cdk/package.json +23 -0
- package/dist/templates/lambda-dynamo-api/cdk/tsconfig.json +14 -0
- package/dist/templates/lambda-dynamo-api/package.json.tmpl +20 -0
- package/dist/templates/lambda-dynamo-api/tsconfig.json +27 -0
- package/dist/templates/lambda-postgres-api/README.md.tmpl +234 -0
- package/dist/templates/lambda-postgres-api/apps/__lambdaName__/index.ts +76 -0
- package/dist/templates/lambda-postgres-api/apps/__lambdaName__/package.json +18 -0
- package/dist/templates/lambda-postgres-api/apps/__lambdaName__/tsconfig.json +26 -0
- package/dist/templates/lambda-postgres-api/cdk/app.ts.tmpl +55 -0
- package/dist/templates/lambda-postgres-api/cdk/cdk.json +4 -0
- package/dist/templates/lambda-postgres-api/cdk/package.json +23 -0
- package/dist/templates/lambda-postgres-api/cdk/tsconfig.json +25 -0
- package/dist/templates/lambda-postgres-api/package.json.tmpl +20 -0
- package/dist/templates/lambda-postgres-api/tsconfig.json +11 -0
- package/dist/templates/static-site/README.md.tmpl +72 -0
- package/dist/templates/static-site/cdk/app.ts.tmpl +50 -0
- package/dist/templates/static-site/cdk/cdk.json +68 -0
- package/dist/templates/static-site/cdk/package.json +23 -0
- package/dist/templates/static-site/cdk/tsconfig.json +9 -0
- package/dist/templates/static-site/frontend/.gitkeep +0 -0
- package/dist/templates/static-site/frontend/README.md +41 -0
- package/dist/templates/static-site/frontend/package.json +9 -0
- package/dist/templates/static-site/package.json.tmpl +19 -0
- package/dist/templates/static-site/tsconfig.json +27 -0
- package/dist/templates/webapp-ecs-dotnet/README.md.tmpl +213 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/Api.csproj +12 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/Dockerfile +30 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/Program.cs +85 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Api.csproj.nuget.dgspec.json +70 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Api.csproj.nuget.g.props +15 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Api.csproj.nuget.g.targets +2 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs +4 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfo.cs +22 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfoInputs.cache +1 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Debug/net8.0/Api.GeneratedMSBuildEditorConfig.editorconfig +19 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Debug/net8.0/Api.GlobalUsings.g.cs +17 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Debug/net8.0/Api.assets.cache +0 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/obj/project.assets.json +75 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/obj/project.nuget.cache +8 -0
- package/dist/templates/webapp-ecs-dotnet/cdk/app.ts.tmpl +60 -0
- package/dist/templates/webapp-ecs-dotnet/cdk/cdk.json +38 -0
- package/dist/templates/webapp-ecs-dotnet/cdk/tsconfig.json +25 -0
- package/dist/templates/webapp-ecs-dotnet/package.json.tmpl +23 -0
- package/dist/templates/webapp-ecs-dotnet/tsconfig.json +26 -0
- package/dist/templates/webapp-ecs-node/README.md.tmpl +207 -0
- package/dist/templates/webapp-ecs-node/apps/api/Dockerfile +33 -0
- package/dist/templates/webapp-ecs-node/apps/api/index.ts +74 -0
- package/dist/templates/webapp-ecs-node/apps/api/package.json +22 -0
- package/dist/templates/webapp-ecs-node/apps/api/tsconfig.json +18 -0
- package/dist/templates/webapp-ecs-node/cdk/app.ts.tmpl +60 -0
- package/dist/templates/webapp-ecs-node/cdk/cdk.json +38 -0
- package/dist/templates/webapp-ecs-node/cdk/tsconfig.json +25 -0
- package/dist/templates/webapp-ecs-node/package.json.tmpl +25 -0
- package/dist/templates/webapp-ecs-node/tsconfig.json +26 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/README.md.tmpl +271 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/Api.csproj +17 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/Dockerfile +30 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/Program.cs +194 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Api.csproj.nuget.dgspec.json +80 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Api.csproj.nuget.g.props +19 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Api.csproj.nuget.g.targets +6 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs +4 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfo.cs +22 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfoInputs.cache +1 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.GeneratedMSBuildEditorConfig.editorconfig +19 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.GlobalUsings.g.cs +17 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.assets.cache +0 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.csproj.AssemblyReference.cache +0 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/project.assets.json +395 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/project.nuget.cache +49 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/cdk/app.ts.tmpl +62 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/cdk/cdk.json +38 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/cdk/tsconfig.json +25 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/package.json.tmpl +23 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/tsconfig.json +26 -0
- package/dist/templates/webapp-ecs-postgres-node/README.md.tmpl +261 -0
- package/dist/templates/webapp-ecs-postgres-node/apps/api/Dockerfile +33 -0
- package/dist/templates/webapp-ecs-postgres-node/apps/api/index.ts +160 -0
- package/dist/templates/webapp-ecs-postgres-node/apps/api/package.json +25 -0
- package/dist/templates/webapp-ecs-postgres-node/apps/api/tsconfig.json +18 -0
- package/dist/templates/webapp-ecs-postgres-node/cdk/app.ts.tmpl +62 -0
- package/dist/templates/webapp-ecs-postgres-node/cdk/cdk.json +38 -0
- package/dist/templates/webapp-ecs-postgres-node/cdk/tsconfig.json +25 -0
- package/dist/templates/webapp-ecs-postgres-node/package.json.tmpl +25 -0
- package/dist/templates/webapp-ecs-postgres-node/tsconfig.json +26 -0
- package/dist/templates/webapp-lambda-dotnet/README.md.tmpl +188 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/Api.csproj +17 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/Program.cs +58 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/aws-lambda-tools-defaults.json +10 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Api.csproj.nuget.dgspec.json +80 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Api.csproj.nuget.g.props +15 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Api.csproj.nuget.g.targets +2 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs +4 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfo.cs +22 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfoInputs.cache +1 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Debug/net8.0/Api.GeneratedMSBuildEditorConfig.editorconfig +19 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Debug/net8.0/Api.GlobalUsings.g.cs +17 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Debug/net8.0/Api.assets.cache +0 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Debug/net8.0/Api.csproj.AssemblyReference.cache +0 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/obj/project.assets.json +708 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/obj/project.nuget.cache +35 -0
- package/dist/templates/webapp-lambda-dotnet/cdk/app.ts.tmpl +59 -0
- package/dist/templates/webapp-lambda-dotnet/cdk/cdk.json +68 -0
- package/dist/templates/webapp-lambda-dotnet/cdk/tsconfig.json +9 -0
- package/dist/templates/webapp-lambda-dotnet/package.json.tmpl +23 -0
- package/dist/templates/webapp-lambda-dotnet/tsconfig.json +27 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/README.md.tmpl +223 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/Api.csproj +18 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/Program.cs +155 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/aws-lambda-tools-defaults.json +10 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Api.csproj.nuget.dgspec.json +84 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Api.csproj.nuget.g.props +19 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Api.csproj.nuget.g.targets +2 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs +4 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfo.cs +22 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfoInputs.cache +1 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Debug/net8.0/Api.GeneratedMSBuildEditorConfig.editorconfig +19 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Debug/net8.0/Api.GlobalUsings.g.cs +17 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Debug/net8.0/Api.assets.cache +0 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Debug/net8.0/Api.csproj.AssemblyReference.cache +0 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/project.assets.json +989 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/project.nuget.cache +223 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/cdk/app.ts.tmpl +65 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/cdk/cdk.json +68 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/cdk/tsconfig.json +9 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/package.json.tmpl +23 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/tsconfig.json +27 -0
- package/dist/templates/webapp-lambda-dynamo-node/README.md.tmpl +189 -0
- package/dist/templates/webapp-lambda-dynamo-node/apps/api/index.ts +109 -0
- package/dist/templates/webapp-lambda-dynamo-node/apps/api/package.json +19 -0
- package/dist/templates/webapp-lambda-dynamo-node/apps/api/tsconfig.json +8 -0
- package/dist/templates/webapp-lambda-dynamo-node/cdk/app.ts.tmpl +65 -0
- package/dist/templates/webapp-lambda-dynamo-node/cdk/cdk.json +68 -0
- package/dist/templates/webapp-lambda-dynamo-node/cdk/tsconfig.json +9 -0
- package/dist/templates/webapp-lambda-dynamo-node/package.json.tmpl +24 -0
- package/dist/templates/webapp-lambda-dynamo-node/tsconfig.json +27 -0
- package/dist/templates/webapp-lambda-node/README.md.tmpl +179 -0
- package/dist/templates/webapp-lambda-node/apps/api/index.ts +100 -0
- package/dist/templates/webapp-lambda-node/apps/api/package.json +17 -0
- package/dist/templates/webapp-lambda-node/apps/api/tsconfig.json +8 -0
- package/dist/templates/webapp-lambda-node/cdk/app.ts.tmpl +59 -0
- package/dist/templates/webapp-lambda-node/cdk/cdk.json +68 -0
- package/dist/templates/webapp-lambda-node/cdk/tsconfig.json +9 -0
- package/dist/templates/webapp-lambda-node/package.json.tmpl +24 -0
- package/dist/templates/webapp-lambda-node/tsconfig.json +27 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/README.md.tmpl +240 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/Api.csproj +19 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/Program.cs +167 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/aws-lambda-tools-defaults.json +10 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Api.csproj.nuget.dgspec.json +88 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Api.csproj.nuget.g.props +15 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Api.csproj.nuget.g.targets +2 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs +4 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfo.cs +22 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfoInputs.cache +1 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.GeneratedMSBuildEditorConfig.editorconfig +19 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.GlobalUsings.g.cs +17 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.assets.cache +0 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/project.assets.json +106 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/project.nuget.cache +15 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/cdk/app.ts.tmpl +61 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/cdk/cdk.json +68 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/cdk/tsconfig.json +9 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/package.json.tmpl +23 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/tsconfig.json +27 -0
- package/dist/templates/webapp-lambda-postgres-node/README.md.tmpl +190 -0
- package/dist/templates/webapp-lambda-postgres-node/apps/api/index.ts +76 -0
- package/dist/templates/webapp-lambda-postgres-node/apps/api/package.json +18 -0
- package/dist/templates/webapp-lambda-postgres-node/apps/api/tsconfig.json +8 -0
- package/dist/templates/webapp-lambda-postgres-node/cdk/app.ts.tmpl +61 -0
- package/dist/templates/webapp-lambda-postgres-node/cdk/cdk.json +68 -0
- package/dist/templates/webapp-lambda-postgres-node/cdk/tsconfig.json +9 -0
- package/dist/templates/webapp-lambda-postgres-node/package.json.tmpl +24 -0
- package/dist/templates/webapp-lambda-postgres-node/tsconfig.json +27 -0
- package/dist/utils/aws.d.ts +4 -0
- package/dist/utils/aws.d.ts.map +1 -0
- package/dist/utils/aws.js +90 -0
- package/dist/utils/aws.js.map +1 -0
- package/dist/utils/dependencies.d.ts +27 -0
- package/dist/utils/dependencies.d.ts.map +1 -0
- package/dist/utils/dependencies.js +267 -0
- package/dist/utils/dependencies.js.map +1 -0
- package/dist/utils/template.d.ts +23 -0
- package/dist/utils/template.d.ts.map +1 -0
- package/dist/utils/template.js +115 -0
- package/dist/utils/template.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import 'source-map-support/register';
|
|
3
|
+
import { App, Aspects, Stack } from 'aws-cdk-lib';
|
|
4
|
+
import { AwsSolutionsChecks, NIST80053R5Checks } from 'cdk-nag';
|
|
5
|
+
import { StaticSite, LambdaApi, Confidentiality, Environment } from '@phila/constructs';
|
|
6
|
+
|
|
7
|
+
const app = new App();
|
|
8
|
+
|
|
9
|
+
// Environment is determined by CDK context
|
|
10
|
+
const environment = app.node.tryGetContext('environment') as Environment;
|
|
11
|
+
|
|
12
|
+
if (!environment) {
|
|
13
|
+
throw new Error('Environment must be specified via context. Use: cdk deploy -c environment=dev');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Read compliance frameworks from context
|
|
17
|
+
const compliance = app.node.tryGetContext('compliance');
|
|
18
|
+
const complianceFrameworks = compliance ? compliance.split(',') : [];
|
|
19
|
+
|
|
20
|
+
// Application context with governance metadata
|
|
21
|
+
const context = {
|
|
22
|
+
appName: '{{appName}}',
|
|
23
|
+
environment,
|
|
24
|
+
department: '{{department}}',
|
|
25
|
+
team: '{{team}}',
|
|
26
|
+
contact: '{{contact}}',
|
|
27
|
+
compliance: complianceFrameworks,
|
|
28
|
+
confidentiality: Confidentiality.{{CONFIDENTIALITY}},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// Stack name follows pattern: {appName}-{environment}
|
|
32
|
+
const stack = new Stack(app, '{{appName}}-' + environment, {
|
|
33
|
+
env: {
|
|
34
|
+
account: process.env.CDK_DEFAULT_ACCOUNT,
|
|
35
|
+
region: process.env.CDK_DEFAULT_REGION || 'us-east-1',
|
|
36
|
+
},
|
|
37
|
+
stackName: '{{appName}}-' + environment,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Create the StaticSite construct for the Nuxt frontend
|
|
41
|
+
new StaticSite(stack, '{{appName}}Site', {
|
|
42
|
+
...context,
|
|
43
|
+
assetDir: '../frontend/dist',
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Create the LambdaApi construct for the API backend
|
|
47
|
+
new LambdaApi(stack, '{{appName}}Api', {
|
|
48
|
+
...context,
|
|
49
|
+
apiId: 'api',
|
|
50
|
+
runtime: 'nodejs20',
|
|
51
|
+
handler: 'index.handler',
|
|
52
|
+
codeDir: '../apps/api',
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Apply compliance checks
|
|
56
|
+
Aspects.of(app).add(new NIST80053R5Checks({ verbose: true }));
|
|
57
|
+
Aspects.of(app).add(new AwsSolutionsChecks({ verbose: true }));
|
|
58
|
+
|
|
59
|
+
app.synth();
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"app": "npx ts-node --prefer-ts-exts app.ts",
|
|
3
|
+
"watch": {
|
|
4
|
+
"include": ["**"],
|
|
5
|
+
"exclude": [
|
|
6
|
+
"README.md",
|
|
7
|
+
"cdk*.json",
|
|
8
|
+
"**/*.d.ts",
|
|
9
|
+
"**/*.js",
|
|
10
|
+
"tsconfig.json",
|
|
11
|
+
"package*.json",
|
|
12
|
+
"yarn.lock",
|
|
13
|
+
"node_modules",
|
|
14
|
+
"test"
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
"context": {
|
|
18
|
+
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
|
|
19
|
+
"@aws-cdk/core:checkSecretUsage": true,
|
|
20
|
+
"@aws-cdk/core:target-partitions": ["aws", "aws-cn"],
|
|
21
|
+
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
|
|
22
|
+
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
|
|
23
|
+
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
|
|
24
|
+
"@aws-cdk/aws-iam:minimizePolicies": true,
|
|
25
|
+
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
|
|
26
|
+
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
|
|
27
|
+
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
|
|
28
|
+
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
|
|
29
|
+
"@aws-cdk/aws-apigateway:disableCloudWatchRole": false,
|
|
30
|
+
"@aws-cdk/core:enablePartitionLiterals": true,
|
|
31
|
+
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
|
|
32
|
+
"@aws-cdk/aws-iam:standardizedServicePrincipals": true,
|
|
33
|
+
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
|
|
34
|
+
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
|
|
35
|
+
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
|
|
36
|
+
"@aws-cdk/aws-route53-patters:useCertificate": true,
|
|
37
|
+
"@aws-cdk/customresources:installLatestAwsSdkDefault": false,
|
|
38
|
+
"@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
|
|
39
|
+
"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
|
|
40
|
+
"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
|
|
41
|
+
"@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
|
|
42
|
+
"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
|
|
43
|
+
"@aws-cdk/aws-redshift:columnId": true,
|
|
44
|
+
"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
|
|
45
|
+
"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
|
|
46
|
+
"@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
|
|
47
|
+
"@aws-cdk/aws-kms:aliasNameRef": true,
|
|
48
|
+
"@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,
|
|
49
|
+
"@aws-cdk/core:includePrefixInUniqueNameGeneration": true,
|
|
50
|
+
"@aws-cdk/aws-efs:denyAnonymousAccess": true,
|
|
51
|
+
"@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true,
|
|
52
|
+
"@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
|
|
53
|
+
"@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true,
|
|
54
|
+
"@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true,
|
|
55
|
+
"@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true,
|
|
56
|
+
"@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true,
|
|
57
|
+
"@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true,
|
|
58
|
+
"@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true,
|
|
59
|
+
"@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": true,
|
|
60
|
+
"@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2": true,
|
|
61
|
+
"@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope": true,
|
|
62
|
+
"@aws-cdk/aws-eks:nodegroupNameAttribute": true,
|
|
63
|
+
"@aws-cdk/aws-ec2:ebsDefaultGp3Volume": true,
|
|
64
|
+
"@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": true,
|
|
65
|
+
"@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": false,
|
|
66
|
+
"@aws-cdk/aws-s3:keepNotificationInImportedBucket": false
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{appName}}",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Web application with Nuxt frontend and Lambda API backend",
|
|
5
|
+
"private": true,
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "npm run build --workspaces",
|
|
8
|
+
"build:frontend": "cd frontend && npm run build",
|
|
9
|
+
"build:api": "cd apps/api && npm run build",
|
|
10
|
+
"dev": "cd frontend && npm run dev",
|
|
11
|
+
"test": "npm test --workspaces --if-present",
|
|
12
|
+
"synth": "cd cdk && cdk synth",
|
|
13
|
+
"deploy": "cd cdk && cdk deploy",
|
|
14
|
+
"diff": "cd cdk && cdk diff"
|
|
15
|
+
},
|
|
16
|
+
"workspaces": [
|
|
17
|
+
"cdk",
|
|
18
|
+
"apps/*",
|
|
19
|
+
"frontend"
|
|
20
|
+
],
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"typescript": "^5.3.0"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"lib": ["ES2020"],
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noImplicitAny": true,
|
|
9
|
+
"strictNullChecks": true,
|
|
10
|
+
"noImplicitThis": true,
|
|
11
|
+
"alwaysStrict": true,
|
|
12
|
+
"noUnusedLocals": false,
|
|
13
|
+
"noUnusedParameters": false,
|
|
14
|
+
"noImplicitReturns": true,
|
|
15
|
+
"noFallthroughCasesInSwitch": false,
|
|
16
|
+
"inlineSourceMap": true,
|
|
17
|
+
"inlineSources": true,
|
|
18
|
+
"experimentalDecorators": true,
|
|
19
|
+
"strictPropertyInitialization": false,
|
|
20
|
+
"typeRoots": ["./node_modules/@types"],
|
|
21
|
+
"skipLibCheck": true,
|
|
22
|
+
"esModuleInterop": true,
|
|
23
|
+
"forceConsistentCasingInFileNames": true,
|
|
24
|
+
"resolveJsonModule": true
|
|
25
|
+
},
|
|
26
|
+
"exclude": ["node_modules", "cdk.out", "frontend"]
|
|
27
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# {{appName}}
|
|
2
|
+
|
|
3
|
+
Web application with Nuxt SSG frontend, .NET Lambda API backend, and PostgreSQL using Philadelphia constructs.
|
|
4
|
+
|
|
5
|
+
Generated on {{timestamp}}
|
|
6
|
+
|
|
7
|
+
## Architecture
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
View the [architecture diagram](https://github.com/CityOfPhiladelphia/phila-ctl/blob/main/packages/constructs/docs/diagrams/webapp-lambda-postgres.drawio) in draw.io or VS Code with the Draw.io extension.
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
### Prerequisites
|
|
16
|
+
|
|
17
|
+
- Node.js 20+
|
|
18
|
+
- .NET 8 SDK
|
|
19
|
+
- AWS CLI configured with SSO
|
|
20
|
+
- AWS profile named `phila-{{appName}}`
|
|
21
|
+
|
|
22
|
+
### Setup
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Install frontend and CDK dependencies
|
|
26
|
+
npm install
|
|
27
|
+
|
|
28
|
+
# Restore .NET dependencies
|
|
29
|
+
cd apps/api && dotnet restore && cd ../..
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Development
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Run frontend dev server
|
|
36
|
+
npm run dev
|
|
37
|
+
|
|
38
|
+
# Build frontend for production
|
|
39
|
+
npm run build:frontend
|
|
40
|
+
|
|
41
|
+
# Build API
|
|
42
|
+
npm run build:api
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Deployment
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Configure AWS profile
|
|
49
|
+
export AWS_PROFILE=phila-{{appName}}
|
|
50
|
+
|
|
51
|
+
# Deploy to dev environment
|
|
52
|
+
city deploy dev
|
|
53
|
+
|
|
54
|
+
# Deploy to test environment
|
|
55
|
+
city deploy test
|
|
56
|
+
|
|
57
|
+
# Deploy to production (requires confirmation)
|
|
58
|
+
city deploy prod
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Shipping Updates
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Ship frontend changes to S3/CloudFront
|
|
65
|
+
city ship dev --web
|
|
66
|
+
|
|
67
|
+
# Ship API changes to Lambda
|
|
68
|
+
city ship dev --lambda api
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Project Structure
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
.
|
|
75
|
+
├── cdk/ # CDK infrastructure code
|
|
76
|
+
│ └── app.ts # Main CDK application
|
|
77
|
+
├── frontend/ # Nuxt 3 SSG frontend
|
|
78
|
+
│ ├── pages/ # File-based routing
|
|
79
|
+
│ ├── app.vue # Root component
|
|
80
|
+
│ └── nuxt.config.ts # Nuxt configuration
|
|
81
|
+
├── apps/ # Backend code
|
|
82
|
+
│ └── api/ # .NET Minimal API with PostgreSQL
|
|
83
|
+
│ ├── Program.cs # API entry point and routes
|
|
84
|
+
│ └── Api.csproj # Project file
|
|
85
|
+
└── city.config.json # City CLI configuration
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Frontend
|
|
89
|
+
|
|
90
|
+
The frontend uses [Nuxt 3](https://nuxt.com) with Static Site Generation (SSG):
|
|
91
|
+
|
|
92
|
+
- Pre-renders to static HTML for S3/CloudFront
|
|
93
|
+
- File-based routing in `pages/` directory
|
|
94
|
+
- TypeScript support enabled
|
|
95
|
+
|
|
96
|
+
### Adding Pages
|
|
97
|
+
|
|
98
|
+
Create Vue files in `frontend/pages/`:
|
|
99
|
+
|
|
100
|
+
```vue
|
|
101
|
+
<!-- frontend/pages/about.vue -->
|
|
102
|
+
<template>
|
|
103
|
+
<div>
|
|
104
|
+
<h1>About</h1>
|
|
105
|
+
</div>
|
|
106
|
+
</template>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
This automatically creates a route at `/about`.
|
|
110
|
+
|
|
111
|
+
## API
|
|
112
|
+
|
|
113
|
+
The API uses [.NET Minimal API](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis) with AWS Lambda hosting and PostgreSQL via Npgsql.
|
|
114
|
+
|
|
115
|
+
### Adding Endpoints
|
|
116
|
+
|
|
117
|
+
Edit `apps/api/Program.cs`:
|
|
118
|
+
|
|
119
|
+
```csharp
|
|
120
|
+
// List all users
|
|
121
|
+
app.MapGet("/users", async (DbConnectionFactory db) =>
|
|
122
|
+
{
|
|
123
|
+
await using var conn = await db.GetConnectionAsync();
|
|
124
|
+
await using var cmd = new NpgsqlCommand("SELECT * FROM users", conn);
|
|
125
|
+
await using var reader = await cmd.ExecuteReaderAsync();
|
|
126
|
+
|
|
127
|
+
var users = new List<object>();
|
|
128
|
+
while (await reader.ReadAsync())
|
|
129
|
+
{
|
|
130
|
+
users.Add(new { Id = reader.GetString(0), Name = reader.GetString(1) });
|
|
131
|
+
}
|
|
132
|
+
return Results.Ok(users);
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Environment Variables
|
|
137
|
+
|
|
138
|
+
Lambda functions automatically receive:
|
|
139
|
+
- `APP_NAME` - Application name ({{appName}})
|
|
140
|
+
- `ENVIRONMENT` - Current environment (dev/test/prod)
|
|
141
|
+
- `DB_SECRET_ARN` - ARN of Secrets Manager secret containing database credentials
|
|
142
|
+
- `DB_NAME` - Database name
|
|
143
|
+
|
|
144
|
+
### Database Connection
|
|
145
|
+
|
|
146
|
+
The `DbConnectionFactory` class handles:
|
|
147
|
+
- Retrieving credentials from AWS Secrets Manager
|
|
148
|
+
- Building connection strings with SSL
|
|
149
|
+
- Connection caching for Lambda warm starts
|
|
150
|
+
|
|
151
|
+
### Building the API
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
# Debug build
|
|
155
|
+
cd apps/api && dotnet build
|
|
156
|
+
|
|
157
|
+
# Release build for deployment
|
|
158
|
+
cd apps/api && dotnet publish -c Release -o publish
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## PostgreSQL
|
|
162
|
+
|
|
163
|
+
The template creates an RDS PostgreSQL instance with:
|
|
164
|
+
- **Engine**: PostgreSQL 15
|
|
165
|
+
- **Instance class**: db.t3.micro (dev), db.t3.small (test/prod)
|
|
166
|
+
- **Storage**: Encrypted with KMS
|
|
167
|
+
- **Credentials**: Stored in Secrets Manager
|
|
168
|
+
- **Network**: VPC with private subnets
|
|
169
|
+
|
|
170
|
+
### Database Migrations
|
|
171
|
+
|
|
172
|
+
Run migrations manually or via a CI/CD pipeline:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
# Connect via bastion host or VPN
|
|
176
|
+
psql -h <rds-endpoint> -U postgres -d {{appName}}
|
|
177
|
+
|
|
178
|
+
# Create tables
|
|
179
|
+
CREATE TABLE items (
|
|
180
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
181
|
+
name VARCHAR(255) NOT NULL,
|
|
182
|
+
description TEXT,
|
|
183
|
+
created_at TIMESTAMP DEFAULT NOW(),
|
|
184
|
+
updated_at TIMESTAMP DEFAULT NOW()
|
|
185
|
+
);
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Serverless Option
|
|
189
|
+
|
|
190
|
+
For variable workloads, use Aurora Serverless:
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
// In cdk/app.ts:
|
|
194
|
+
new LambdaPostgresApi(stack, '{{appName}}Api', {
|
|
195
|
+
...context,
|
|
196
|
+
serverless: true, // Use Aurora Serverless v2
|
|
197
|
+
});
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Resources Created
|
|
201
|
+
|
|
202
|
+
This application creates:
|
|
203
|
+
|
|
204
|
+
**Frontend:**
|
|
205
|
+
- **S3 Bucket** - Static asset storage
|
|
206
|
+
- **CloudFront Distribution** - CDN with HTTPS
|
|
207
|
+
- **Origin Access Control** - Secure S3 access
|
|
208
|
+
|
|
209
|
+
**API:**
|
|
210
|
+
- **API Gateway REST API** - HTTP endpoint
|
|
211
|
+
- **Lambda Function** - .NET 8 serverless compute
|
|
212
|
+
- **RDS PostgreSQL** - Relational database
|
|
213
|
+
- **Secrets Manager** - Database credentials
|
|
214
|
+
- **VPC Security Group** - Network security
|
|
215
|
+
- **IAM Role** - Permissions for Lambda and database
|
|
216
|
+
|
|
217
|
+
**Shared:**
|
|
218
|
+
- **SSM Parameters** - Resource discovery
|
|
219
|
+
- **CloudWatch Logs** - Application logs
|
|
220
|
+
- **KMS Keys** - Encryption
|
|
221
|
+
|
|
222
|
+
## URLs
|
|
223
|
+
|
|
224
|
+
After deployment, URLs are available via:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
# Frontend URL
|
|
228
|
+
city config list --env dev | grep cloudfront
|
|
229
|
+
|
|
230
|
+
# API URL
|
|
231
|
+
city config list --env dev | grep api
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Support
|
|
235
|
+
|
|
236
|
+
For issues or questions:
|
|
237
|
+
- [Philadelphia Infrastructure Library Documentation](https://github.com/CityOfPhiladelphia/phila-ctl)
|
|
238
|
+
- [.NET Minimal APIs Documentation](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis)
|
|
239
|
+
- [Npgsql Documentation](https://www.npgsql.org/)
|
|
240
|
+
- [Nuxt Documentation](https://nuxt.com/docs)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!-- ABOUTME: .NET 8 Minimal API project with PostgreSQL for AWS Lambda -->
|
|
2
|
+
<!-- ABOUTME: Includes Npgsql and AWS SDK for database connectivity -->
|
|
3
|
+
<Project Sdk="Microsoft.NET.Sdk.Web">
|
|
4
|
+
<PropertyGroup>
|
|
5
|
+
<TargetFramework>net8.0</TargetFramework>
|
|
6
|
+
<Nullable>enable</Nullable>
|
|
7
|
+
<ImplicitUsings>enable</ImplicitUsings>
|
|
8
|
+
<OutputType>Exe</OutputType>
|
|
9
|
+
<AssemblyName>Api</AssemblyName>
|
|
10
|
+
<RootNamespace>Api</RootNamespace>
|
|
11
|
+
</PropertyGroup>
|
|
12
|
+
|
|
13
|
+
<ItemGroup>
|
|
14
|
+
<PackageReference Include="Amazon.Lambda.AspNetCoreServer.Hosting" Version="1.7.2" />
|
|
15
|
+
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.4" />
|
|
16
|
+
<PackageReference Include="AWSSDK.SecretsManager" Version="3.7.405.4" />
|
|
17
|
+
<PackageReference Include="Npgsql" Version="8.0.5" />
|
|
18
|
+
</ItemGroup>
|
|
19
|
+
</Project>
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// ABOUTME: Minimal API Lambda handler with PostgreSQL database scaffolding
|
|
2
|
+
// ABOUTME: Provides REST endpoints with database connection examples
|
|
3
|
+
|
|
4
|
+
using System.Text.Json;
|
|
5
|
+
using Amazon.SecretsManager;
|
|
6
|
+
using Amazon.SecretsManager.Model;
|
|
7
|
+
using Npgsql;
|
|
8
|
+
|
|
9
|
+
var builder = WebApplication.CreateBuilder(args);
|
|
10
|
+
|
|
11
|
+
// Add AWS Lambda hosting
|
|
12
|
+
builder.Services.AddAWSLambdaHosting(LambdaEventSource.HttpApi);
|
|
13
|
+
|
|
14
|
+
// Register database connection factory as singleton
|
|
15
|
+
builder.Services.AddSingleton<DbConnectionFactory>();
|
|
16
|
+
|
|
17
|
+
var app = builder.Build();
|
|
18
|
+
|
|
19
|
+
// Health check endpoint
|
|
20
|
+
app.MapGet("/health", () => Results.Ok(new
|
|
21
|
+
{
|
|
22
|
+
Status = "healthy",
|
|
23
|
+
Timestamp = DateTime.UtcNow.ToString("o")
|
|
24
|
+
}));
|
|
25
|
+
|
|
26
|
+
// Hello world endpoint
|
|
27
|
+
app.MapGet("/hello", (HttpContext context) =>
|
|
28
|
+
{
|
|
29
|
+
var name = context.Request.Query["name"].FirstOrDefault() ?? "World";
|
|
30
|
+
return Results.Ok(new
|
|
31
|
+
{
|
|
32
|
+
Message = $"Hello, {name}!",
|
|
33
|
+
AppName = Environment.GetEnvironmentVariable("APP_NAME"),
|
|
34
|
+
Environment = Environment.GetEnvironmentVariable("ENVIRONMENT"),
|
|
35
|
+
Timestamp = DateTime.UtcNow.ToString("o")
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Example: List items from database
|
|
40
|
+
app.MapGet("/items", async (DbConnectionFactory db) =>
|
|
41
|
+
{
|
|
42
|
+
// TODO: Implement database query
|
|
43
|
+
// await using var conn = await db.GetConnectionAsync();
|
|
44
|
+
// await using var cmd = new NpgsqlCommand("SELECT * FROM items", conn);
|
|
45
|
+
// await using var reader = await cmd.ExecuteReaderAsync();
|
|
46
|
+
// var items = new List<object>();
|
|
47
|
+
// while (await reader.ReadAsync())
|
|
48
|
+
// {
|
|
49
|
+
// items.Add(new { Id = reader.GetString(0), Name = reader.GetString(1) });
|
|
50
|
+
// }
|
|
51
|
+
// return Results.Ok(items);
|
|
52
|
+
|
|
53
|
+
return Results.Ok(new
|
|
54
|
+
{
|
|
55
|
+
Items = Array.Empty<object>(),
|
|
56
|
+
Message = "Database query not implemented - see code comments for Npgsql example"
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Example: Create item in database
|
|
61
|
+
app.MapPost("/items", async (ItemRequest request, DbConnectionFactory db) =>
|
|
62
|
+
{
|
|
63
|
+
Console.WriteLine($"Creating item: {request.Name}");
|
|
64
|
+
|
|
65
|
+
// TODO: Implement database insert
|
|
66
|
+
// await using var conn = await db.GetConnectionAsync();
|
|
67
|
+
// await using var cmd = new NpgsqlCommand(
|
|
68
|
+
// "INSERT INTO items (name, description) VALUES (@name, @desc) RETURNING id", conn);
|
|
69
|
+
// cmd.Parameters.AddWithValue("name", request.Name);
|
|
70
|
+
// cmd.Parameters.AddWithValue("desc", request.Description ?? (object)DBNull.Value);
|
|
71
|
+
// var id = await cmd.ExecuteScalarAsync();
|
|
72
|
+
// return Results.Created($"/items/{id}", new { Id = id, Name = request.Name });
|
|
73
|
+
|
|
74
|
+
return Results.Created($"/items/{Guid.NewGuid()}", new
|
|
75
|
+
{
|
|
76
|
+
Message = "Item created (database insert not implemented)",
|
|
77
|
+
Item = request
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Example: Get item by ID
|
|
82
|
+
app.MapGet("/items/{id}", async (string id, DbConnectionFactory db) =>
|
|
83
|
+
{
|
|
84
|
+
// TODO: Implement database query
|
|
85
|
+
// await using var conn = await db.GetConnectionAsync();
|
|
86
|
+
// await using var cmd = new NpgsqlCommand("SELECT * FROM items WHERE id = @id", conn);
|
|
87
|
+
// cmd.Parameters.AddWithValue("id", id);
|
|
88
|
+
// await using var reader = await cmd.ExecuteReaderAsync();
|
|
89
|
+
// if (!await reader.ReadAsync())
|
|
90
|
+
// {
|
|
91
|
+
// return Results.NotFound(new { Error = "Item not found" });
|
|
92
|
+
// }
|
|
93
|
+
// return Results.Ok(new { Id = reader.GetString(0), Name = reader.GetString(1) });
|
|
94
|
+
|
|
95
|
+
return Results.Ok(new
|
|
96
|
+
{
|
|
97
|
+
Id = id,
|
|
98
|
+
Message = $"Database query not implemented for item {id}"
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
app.Run();
|
|
103
|
+
|
|
104
|
+
/// <summary>
|
|
105
|
+
/// Request model for creating items
|
|
106
|
+
/// </summary>
|
|
107
|
+
public record ItemRequest(string Name, string? Description);
|
|
108
|
+
|
|
109
|
+
/// <summary>
|
|
110
|
+
/// Factory for creating database connections using credentials from Secrets Manager.
|
|
111
|
+
/// Credentials are cached after first retrieval for Lambda performance.
|
|
112
|
+
/// </summary>
|
|
113
|
+
public class DbConnectionFactory
|
|
114
|
+
{
|
|
115
|
+
private string? _connectionString;
|
|
116
|
+
|
|
117
|
+
public async Task<NpgsqlConnection> GetConnectionAsync()
|
|
118
|
+
{
|
|
119
|
+
if (_connectionString == null)
|
|
120
|
+
{
|
|
121
|
+
_connectionString = await BuildConnectionStringAsync();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
var conn = new NpgsqlConnection(_connectionString);
|
|
125
|
+
await conn.OpenAsync();
|
|
126
|
+
return conn;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private static async Task<string> BuildConnectionStringAsync()
|
|
130
|
+
{
|
|
131
|
+
var secretArn = Environment.GetEnvironmentVariable("DB_SECRET_ARN");
|
|
132
|
+
var dbName = Environment.GetEnvironmentVariable("DB_NAME");
|
|
133
|
+
|
|
134
|
+
if (string.IsNullOrEmpty(secretArn))
|
|
135
|
+
{
|
|
136
|
+
throw new InvalidOperationException("DB_SECRET_ARN environment variable not set");
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
using var client = new AmazonSecretsManagerClient();
|
|
140
|
+
var response = await client.GetSecretValueAsync(new GetSecretValueRequest
|
|
141
|
+
{
|
|
142
|
+
SecretId = secretArn
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
var credentials = JsonSerializer.Deserialize<DbCredentials>(response.SecretString)
|
|
146
|
+
?? throw new InvalidOperationException("Failed to deserialize database credentials");
|
|
147
|
+
|
|
148
|
+
return new NpgsqlConnectionStringBuilder
|
|
149
|
+
{
|
|
150
|
+
Host = credentials.Host,
|
|
151
|
+
Port = credentials.Port,
|
|
152
|
+
Database = dbName ?? credentials.Database,
|
|
153
|
+
Username = credentials.Username,
|
|
154
|
+
Password = credentials.Password,
|
|
155
|
+
SslMode = SslMode.Require,
|
|
156
|
+
TrustServerCertificate = true
|
|
157
|
+
}.ConnectionString;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
private record DbCredentials(
|
|
161
|
+
string Host,
|
|
162
|
+
int Port,
|
|
163
|
+
string Database,
|
|
164
|
+
string Username,
|
|
165
|
+
string Password
|
|
166
|
+
);
|
|
167
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Information": ["Configuration used by AWS Lambda .NET tooling when deploying"],
|
|
3
|
+
"profile": "",
|
|
4
|
+
"region": "",
|
|
5
|
+
"configuration": "Release",
|
|
6
|
+
"function-runtime": "dotnet8",
|
|
7
|
+
"function-memory-size": 256,
|
|
8
|
+
"function-timeout": 30,
|
|
9
|
+
"function-handler": "Api"
|
|
10
|
+
}
|