error exec CDK from BuildSpec

0

Hi All,

In My BuildProject/BuildSpec (in my STG Account), I run this command :

- cdk deploy --require-approval never

it gives me this error :

mystackName failed: Error: Need to perform AWS calls for account xxxxxxxx(DEV_ACCOUNT_ID), but the current credentials are for yyyyyy (STG_ACCOUNT_ID)

It worked fine for another branch but when I put the name of another branch it gives me that error, not sure what happens?

Thank you.

Jess
gefragt vor 2 Jahren1171 Aufrufe
1 Antwort
0
Akzeptierte Antwort

Check you code that defines the stack and env. I am betting that you have defined the Dev account as the env to deploy the stack to but are running cdk deploy in your staging account.

For example

import 'source-map-support/register';
import { App } from 'aws-cdk-lib';
import { WorkspacesStack } from '../lib/workspaces-stack';

const app = new App();
const sharedStack = new WorkspacesStack(app, 'WorkspacesStack', {
  env: {
    account: '123456789012' <<< I am betting that you have your DEV Account ID there but trying to deploy to your staging account.
    region: 'us-east-1',
  },
});

If your intent to just be able to take your cdk and run those commands in any account. Then you will want to use new process.env.CDK_DEFAULT_ACCOUNT as detailed in the CDK Environment docs

MyDevStack(app, 'dev', { 
  env: { 
    account: process.env.CDK_DEFAULT_ACCOUNT, 
    region: process.env.CDK_DEFAULT_REGION 
}});

Otherwise if you are looking to build a pipeline you will want to look at bootstrapping with using the --trust parameter and CDK Pipelines

AWS
beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen