Skip to content

Commit d412ed3

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

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,29 @@ 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+
// Create temporary AWS credentials file for container mounting
34+
const awsCredentialsDir = path.resolve(_path, '.aws');
35+
fs.ensureDirSync(awsCredentialsDir);
36+
37+
const credentialsContent = `[default]
38+
aws_access_key_id = ${process.env.AWS_ACCESS_KEY_ID}
39+
aws_secret_access_key = ${process.env.AWS_SECRET_ACCESS_KEY}
40+
aws_session_token = ${process.env.AWS_SESSION_TOKEN}
41+
`;
42+
43+
const configContent = `[default]
44+
region = ${process.env.AWS_REGION || process.env.AWS_DEFAULT_REGION || 'us-west-1'}
45+
`;
46+
47+
fs.writeFileSync(path.resolve(awsCredentialsDir, 'credentials'), credentialsContent);
48+
fs.writeFileSync(path.resolve(awsCredentialsDir, 'config'), configContent);
49+
50+
// Mount the temporary credentials directory
51+
volumes.push('./.aws:/root/.aws:ro');
52+
}
3053
const compose: any = {
3154
version: '2.2',
3255
services: {
@@ -46,6 +69,9 @@ export function getComposePath(type: string, fixture: Fixture, isLocal: boolean)
4669
image: `cubejs/cubestore:${process.arch === 'arm64' ? 'arm64v8' : 'latest'}`,
4770
ports: ['3030'],
4871
restart: 'always',
72+
...(process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY && process.env.AWS_SESSION_TOKEN ? {
73+
volumes: ['./.aws:/root/.aws:ro']
74+
} : {})
4975
}
5076
}
5177
};

0 commit comments

Comments
 (0)