Skip to content

Commit

Permalink
better typing
Browse files Browse the repository at this point in the history
  • Loading branch information
iliapolo committed Aug 29, 2024
1 parent 02892e2 commit 276ef63
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
5 changes: 4 additions & 1 deletion lib/private/handlers/container-images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ export class ContainerImageAssetHandler implements IAssetHandler {

const destination = await replaceAwsPlaceholders(this.asset.destination, this.host.aws);
const ecr = await this.host.aws.ecrClient({
...destination,
assumeRoleArn: destination.assumeRoleArn,
assumeRoleExternalId: destination.assumeRoleExternalId,
assumeRoleSessionTags: {},
region: destination.region,
quiet: options.quiet,
});
const account = async () => (await this.host.aws.discoverCurrentAccount())?.accountId;
Expand Down
22 changes: 19 additions & 3 deletions lib/private/handlers/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ export class FileAssetHandler implements IAssetHandler {
const s3Url = `s3://${destination.bucketName}/${destination.objectKey}`;
try {
const s3 = await this.host.aws.s3Client({
...destination,
assumeRoleArn: destination.assumeRoleArn,
assumeRoleExternalId: destination.assumeRoleExternalId,
assumeRoleSessionTags: {},
region: destination.region,
quiet: true,
});
this.host.emitMessage(EventType.CHECK, `Check ${s3Url}`);
Expand All @@ -53,14 +56,27 @@ export class FileAssetHandler implements IAssetHandler {
public async publish(): Promise<void> {
const destination = await replaceAwsPlaceholders(this.asset.destination, this.host.aws);
const s3Url = `s3://${destination.bucketName}/${destination.objectKey}`;
const s3 = await this.host.aws.s3Client(destination);
const s3 = await this.host.aws.s3Client({
assumeRoleArn: destination.assumeRoleArn,
assumeRoleExternalId: destination.assumeRoleExternalId,
assumeRoleSessionTags: {},
region: destination.region,
});
this.host.emitMessage(EventType.CHECK, `Check ${s3Url}`);

const bucketInfo = BucketInformation.for(this.host);

// A thunk for describing the current account. Used when we need to format an error
// message, not in the success case.
const account = async () => (await this.host.aws.discoverTargetAccount(destination))?.accountId;
const account = async () =>
(
await this.host.aws.discoverTargetAccount({
assumeRoleArn: destination.assumeRoleArn,
assumeRoleExternalId: destination.assumeRoleExternalId,
assumeRoleSessionTags: {},
region: destination.region,
})
)?.accountId;
switch (await bucketInfo.bucketOwnership(s3, destination.bucketName)) {
case BucketOwnership.MINE:
break;
Expand Down

0 comments on commit 276ef63

Please sign in to comment.