Skip to content

Commit 4a1dd70

Browse files
committed
enable IRSA credential mounting for containerized AWS tests
1 parent 980e566 commit 4a1dd70

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

packages/cubejs-testing-drivers/src/helpers/getComposePath.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@ export function getComposePath(type: string, fixture: Fixture, isLocal: boolean)
2727
'./package.json:/cube/conf/package.json',
2828
'./model/ecommerce.yaml:/cube/conf/model/ecommerce.yaml',
2929
];
30+
31+
// Add AWS credential mounting for IRSA-enabled tests
32+
if (process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY && process.env.AWS_SESSION_TOKEN) {
33+
const awsCredentialsDir = path.resolve(_path, '.aws');
34+
fs.ensureDirSync(awsCredentialsDir);
35+
36+
const credentialsContent = `[default]
37+
aws_access_key_id = ${process.env.AWS_ACCESS_KEY_ID}
38+
aws_secret_access_key = ${process.env.AWS_SECRET_ACCESS_KEY}
39+
aws_session_token = ${process.env.AWS_SESSION_TOKEN}
40+
`;
41+
42+
const configContent = `[default]
43+
region = ${process.env.AWS_REGION || process.env.AWS_DEFAULT_REGION || 'us-west-1'}
44+
`;
45+
46+
fs.writeFileSync(path.resolve(awsCredentialsDir, 'credentials'), credentialsContent);
47+
fs.writeFileSync(path.resolve(awsCredentialsDir, 'config'), configContent);
48+
49+
volumes.push('./.aws:/root/.aws:ro');
50+
}
3051
const compose: any = {
3152
version: '2.2',
3253
services: {
@@ -46,6 +67,9 @@ export function getComposePath(type: string, fixture: Fixture, isLocal: boolean)
4667
image: `cubejs/cubestore:${process.arch === 'arm64' ? 'arm64v8' : 'latest'}`,
4768
ports: ['3030'],
4869
restart: 'always',
70+
...(process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY && process.env.AWS_SESSION_TOKEN ? {
71+
volumes: ['./.aws:/root/.aws:ro']
72+
} : {})
4973
}
5074
}
5175
};

0 commit comments

Comments
 (0)