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(elasticloadbalancingv2): logaccesslogs throws error if region is not set using environment #27938

Conversation

jakob-lj
Copy link

When calling logAccessLogs on an Application Load balancer (v2), there is a check getting the region of the stack. This is later used for getting the account where the stack is deployed. However, if the account is undefined, the service principal (logdelivery.elasticloadbalancing.amazonaws.com) is used. So the region should not be required, as it is only used for finding the account, which is not required.

Therefore, it should make sense to return the service principal also if the region is undefined, which is described in the issue.

Closes #27432 .


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1 labels Nov 10, 2023
@aws-cdk-automation aws-cdk-automation requested a review from a team November 10, 2023 20:16
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@jakob-lj jakob-lj force-pushed the jakob-lj/fix-aws_base_loadbalancer_access_logs_region_bug branch from b952bf0 to 9973189 Compare November 10, 2023 20:19
@jakob-lj jakob-lj changed the title fix(elasticloadbalancingv2) logaccesslogs throws error if region is not set using environment fix(elasticloadbalancingv2): logaccesslogs throws error if region is not set using environment Nov 10, 2023
@aws-cdk-automation aws-cdk-automation dismissed their stale review November 10, 2023 20:20

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 9973189
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Nov 10, 2023
@@ -307,7 +307,7 @@ export abstract class BaseLoadBalancer extends Resource {
protected resourcePolicyPrincipal(): iam.IPrincipal {
const region = Stack.of(this).region;
if (Token.isUnresolved(region)) {
throw new Error('Region is required to enable ELBv2 access logging');
return new iam.ServicePrincipal('logdelivery.elasticloadbalancing.amazonaws.com');
Copy link
Contributor

@tmokmss tmokmss Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only newer regions use this principal for elb logging (doc), and other (older) regions still require the elb-account-id for each region.

So with this change, you can synthesize an environment-agnostic template using elb access logging, but it won't work in those older regions. I guess that's not the desired result. Correct me if I misunderstand something 🙏

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.

Then the proposed solution in the issue wont work. I should have done some more research here before opening PR. Thank you for review @tmokmss . Would you like to inform in the issue as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure I commented to the original issue, and thank you for working on the cdk issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1 pr/needs-maintainer-review This PR needs a review from a Core Team Member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

elasticloadbalancing: allow logAccessLogs on environment agnostic stack
3 participants