Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sqs): imported queue ignores environment from arn #27906

Merged
merged 5 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/aws-cdk-lib/aws-sqs/lib/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ export class Queue extends QueueBase {
}
}

return new Import(scope, id);
return new Import(scope, id, {
environmentFromArn: attrs.queueArn,
});
}

/**
Expand Down
32 changes: 32 additions & 0 deletions packages/aws-cdk-lib/aws-sqs/test/sqs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,38 @@ describe('export and import', () => {
});
expect(stack.resolve(imports.queueName)).toEqual('queue1');
});

test('sets account for imported queue env by fromQueueAttributes', () => {
const stack = new Stack();
const imported = sqs.Queue.fromQueueAttributes(stack, 'Imported', {
queueArn: 'arn:aws:sqs:us-west-2:999999999999:queue',
});

expect(imported.env.account).toEqual('999999999999');
});

test('sets region for imported queue env by fromQueueAttributes', () => {
const stack = new Stack();
const imported = sqs.Queue.fromQueueAttributes(stack, 'Imported', {
queueArn: 'arn:aws:sqs:us-west-2:999999999999:queue',
});

expect(imported.env.region).toEqual('us-west-2');
});

test('sets account for imported queue env by fromQueueArn', () => {
const stack = new Stack();
const imported = sqs.Queue.fromQueueArn(stack, 'Imported', 'arn:aws:sqs:us-west-2:999999999999:queue');

expect(imported.env.account).toEqual('999999999999');
});

test('sets region for imported queue env by fromQueueArn', () => {
const stack = new Stack();
const imported = sqs.Queue.fromQueueArn(stack, 'Imported', 'arn:aws:sqs:us-west-2:123456789012:queue');

expect(imported.env.region).toEqual('us-west-2');
});
});

describe('grants', () => {
Expand Down