feat(infra): add aws lambda pulumi deployment target

This commit is contained in:
2026-03-23 13:56:15 +04:00
parent 2688d66f33
commit ee8c53d89b
20 changed files with 2492 additions and 861 deletions

View File

@@ -0,0 +1,38 @@
const repositoryUrl = process.env.AWS_ECR_REPOSITORY_URL
const imageTag = process.env.AWS_ECR_IMAGE_TAG ?? 'latest'
const awsRegion = process.env.AWS_REGION
if (!repositoryUrl) {
throw new Error('AWS_ECR_REPOSITORY_URL environment variable is required')
}
if (!awsRegion) {
throw new Error('AWS_REGION environment variable is required')
}
const imageRef = `${repositoryUrl}:${imageTag}`
const passwordProcess = Bun.spawnSync(['aws', 'ecr', 'get-login-password', '--region', awsRegion], {
stdout: 'pipe',
stderr: 'inherit'
})
if (passwordProcess.exitCode !== 0) {
throw new Error('Failed to obtain an ECR login password')
}
const loginProcess = Bun.spawnSync(
['docker', 'login', '--username', 'AWS', '--password-stdin', repositoryUrl.split('/')[0]!],
{
stdin: passwordProcess.stdout,
stdout: 'inherit',
stderr: 'inherit'
}
)
if (loginProcess.exitCode !== 0) {
throw new Error('Failed to login to ECR')
}
await Bun.$`docker build -f apps/bot/Dockerfile.lambda -t ${imageRef} .`
await Bun.$`docker push ${imageRef}`