pulumi-aws icon indicating copy to clipboard operation
pulumi-aws copied to clipboard

Pulumi aws.alb.LoadBalancer configuration for access_logs is not enabling the logs attribute for load balancer

Open pk-hugo opened this issue 1 year ago • 2 comments

Describe what happened

When using the pulumi python for creating load balancer we are not able to configure the access_logs for the alb if we have a prefix. It only works if we don't add any prefix.

The ideal behaviour should be that the alb should create the directory for prefix by itself and the configuration should work. This is the case if we do it manually. But with pulumi this is not working like that and won't throw any error as well.

The preview shows the change in access_logs and pulumi up won't give any error. But the access_logs are never enabled for the load balancer.

Sample program

This can be reproduced with the same code given in the documentation as well. https://www.pulumi.com/registry/packages/aws/api-docs/alb/loadbalancer/

import pulumi
import pulumi_aws as aws

test = aws.lb.LoadBalancer("test",
    name="test-lb-tf",
    internal=False,
    load_balancer_type="application",
    security_groups=[lb_sg["id"]],
    subnets=[subnet["id"] for subnet in public],
    enable_deletion_protection=True,
    access_logs={
        "bucket": lb_logs["id"],
        "prefix": "test-lb",
        "enabled": True,
    },
    tags={
        "Environment": "production",
    })

Log output

preview output

 ~   ├─ aws:alb:LoadBalancer           aws-ag-foo-alb                  update     [diff: ~accessLogs]
 ~   ├─ aws:alb:LoadBalancer           aws-ag-bar-alb                    update     [diff: ~accessLogs]

up output

 ~   ├─ aws:alb:LoadBalancer           aws-ag-foo-alb                   updated     [diff: ~accessLogs]
 ~   ├─ aws:alb:LoadBalancer           aws-ag-bar-alb                     updated     [diff: ~accessLogs]

preview output again

~   ├─ aws:alb:LoadBalancer           aws-ag-foo-alb                  update     [diff: ~accessLogs]
 ~   ├─ aws:alb:LoadBalancer           aws-ag-bar-alb                    update     [diff: ~accessLogs]

Affected Resource(s)

Enabling Access Logs for AWS ALB.

Output of pulumi about

CLI
Version 3.123.0 Go Version go1.22.5 Go Compiler gc

Plugins KIND NAME VERSION resource aws 6.41.0 resource aws-native 0.108.4 language python 3.11.9

Host
OS darwin Version 14.5 Arch arm64

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

pk-hugo avatar Jul 25 '24 15:07 pk-hugo

Thank you for pointing this out and suggesting a workaround. Our team will take a look as time permits.

t0yv0 avatar Jul 26 '24 14:07 t0yv0

Hi @pk-hugo, would you care to try again? Specifying a prefix is working fine for me. I'm using Python as well:

import pulumi_aws as aws

aws.lb.LoadBalancer(
    "test"
    access_logs={
        "bucket": <bucket name>,
        "enabled": True,
        "prefix": <prefix>,
    },
    internal=True,
    security_groups=[<security_group_id>],
    subnets=[<subnets>],
)

I'm using Pulumi 3.135.1 and Pulumi-AWS 6.54.2.

Sodki avatar Oct 10 '24 18:10 Sodki