11import { ECRClient } from '@aws-sdk/client-ecr'
22import { IAMClient } from '@aws-sdk/client-iam'
33import { IoTClient } from '@aws-sdk/client-iot'
4- import { GetCallerIdentityCommand , STS } from '@aws-sdk/client-sts'
4+ import { STS } from '@aws-sdk/client-sts'
55import path from 'node:path'
66import { getIoTEndpoint } from '../aws/getIoTEndpoint.js'
77import { getOrBuildDockerImage } from '../aws/getOrBuildDockerImage.js'
@@ -12,6 +12,7 @@ import { debug } from '../cli/log.js'
1212import pJSON from '../package.json'
1313import { BackendApp } from './BackendApp.js'
1414import { ensureGitHubOIDCProvider } from './ensureGitHubOIDCProvider.js'
15+ import { env } from './helpers/env.js'
1516import { packLayer } from './helpers/lambdas/packLayer.js'
1617import { packBackendLambdas } from './packBackendLambdas.js'
1718import { ECR_NAME } from './stacks/stackConfig.js'
@@ -27,6 +28,8 @@ const sts = new STS({})
2728const ecr = new ECRClient ( { } )
2829const iam = new IAMClient ( { } )
2930
31+ const accountEnv = await env ( { sts } )
32+
3033const packagesInLayer : string [ ] = [
3134 '@nordicsemiconductor/from-env' ,
3235 '@nordicsemiconductor/timestream-helpers' ,
@@ -38,9 +41,7 @@ const packagesInLayer: string[] = [
3841 'lodash-es' ,
3942 '@middy/core' ,
4043]
41- const accountId = ( await sts . send ( new GetCallerIdentityCommand ( { } ) ) )
42- . Account as string
43- const certsDir = path . join ( process . cwd ( ) , 'certificates' , accountId )
44+ const certsDir = path . join ( process . cwd ( ) , 'certificates' , accountEnv . account )
4445const mqttBridgeCertificate = await ensureMQTTBridgeCredentials ( {
4546 iot,
4647 certsDir,
@@ -86,10 +87,9 @@ new BackendApp({
8687 imageTag,
8788 repositoryUri,
8889 } ,
89- region :
90- process . env . AWS_REGION ?? process . env . AWS_DEFAULT_REGION ?? 'eu-west-1' ,
9190 repository,
9291 gitHubOICDProviderArn : await ensureGitHubOIDCProvider ( {
9392 iam,
9493 } ) ,
94+ env : accountEnv ,
9595} )
0 commit comments