https://pulumi.com logo
#java
Title
# java
f

full-art-3978

03/06/2024, 12:30 AM
Any help with ALB error?
Copy code
var alb = new ApplicationLoadBalancer("app-lb", ApplicationLoadBalancerArgs.builder()
                    .securityGroups(dbSecurityGroup.id().applyValue(id -> List.of(id)))
                    .subnetIds(vpc.publicSubnetIds())
                    .internal(false)
                    .defaultTargetGroup(TargetGroupArgs.builder()
                            .targetType("ip")
                            .port(8080)
                            .vpcId(vpc.vpcId())
                            .protocol("HTTP")
                            .healthCheck(TargetGroupHealthCheckArgs.builder()
                                    .enabled(false)
//                                    .interval(100000)
                                    .build())
                            .targetHealthStates(TargetGroupTargetHealthStateArgs.builder()
                                    .enableUnhealthyConnectionTermination(true)
                                    .build())

                            .build())

                    .build());
I am getting error:
java.lang.UnsupportedOperationException: Convert [<http://com.pulumi.aws.lb|com.pulumi.aws.lb>.TargetGroup.targetHealthStates]: Error converting 'java.util.Collections$UnmodifiableRandomAccessList' to 'TypeShape{type=interface java.util.List, parameters=[TypeShape{type=class <http://com.pulumi.aws.lb|com.pulumi.aws.lb>.outputs.TargetGroupTargetHealthState, parameters=[]}]}'. null
at com.pulumi.serialization.internal.Converter.convertObjectUntyped(Converter.java:119) at com.pulumi.serialization.internal.Converter.convertValue(Converter.java:86) at com.pulumi.core.internal.OutputCompletionSource.setValue(OutputCompletionSource.java:95) at com.pulumi.deployment.internal.DeploymentImpl$ReadOrRegisterResourceInternal.lambda$completeResourceAsync$0(DeploymentImpl.java:1187) at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646) at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188) Caused by: java.lang.NullPointerException at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:903) at com.google.common.collect.ImmutableList$Builder.add(ImmutableList.java:815) at com.pulumi.serialization.internal.Converter.tryConvertList(Converter.java:642) at com.pulumi.serialization.internal.Converter.tryConvertObjectInner(Converter.java:277) at com.pulumi.serialization.internal.Converter.convertObjectUntyped(Converter.java:115)
a

adamant-lawyer-19698

03/11/2024, 2:10 AM
first to check all classes are from
com.pulumi.aws.alb
then try code without health check settings
and if still not working, here I have a working example, not using default target group
Copy code
public ClusterDnsName(String dnsName, Output<String> coordinatePrivateIp, Output<String> swarmSecurityGroup, DeployInfraReference deployInfra) {
        String zoneId = deployInfra.getDeployHostedZoneId();

        LoadBalancer alb = new LoadBalancer("alb-" + dnsName, LoadBalancerArgs.builder()
                .enableCrossZoneLoadBalancing(true)
                .enableDeletionProtection(false)
                .internal(false)
                .name("alb-" + dnsName)
                .securityGroups(Output.all(swarmSecurityGroup))
                .subnets(Output.all(deployInfra.getPublicSubnetId(), deployInfra.getPublicSubnetId2()))
                .tags(App.TAGS)
                .build());

        Record dnsRecord = new Record("record-a-" + dnsName, RecordArgs.builder()
                .aliases(List.of(RecordAliasArgs.builder()
                        .evaluateTargetHealth(false)
                        .name(alb.dnsName())
                        .zoneId(alb.zoneId())
                        .build()))
                .name(dnsName)
                .type("A")
                .zoneId(zoneId)
                .build());

        TargetGroup tg = new TargetGroup("tg-" + dnsName, TargetGroupArgs.builder()
                .ipAddressType("ipv4")
                .name("tg-" + dnsName)
                .port(80)
                .protocol("HTTP")
                .tags(App.TAGS)
                .targetType("ip")
                .vpcId(deployInfra.getVpcId())
                .build());

        TargetGroupAttachment attachment = new TargetGroupAttachment("tga-" + dnsName, TargetGroupAttachmentArgs.builder()
                .port(80)
                .targetGroupArn(tg.arn())
                .targetId(coordinatePrivateIp)
                .build());

        Listener listener = new Listener("listener-" + dnsName, ListenerArgs.builder()
                .certificateArn(deployInfra.getWildSslCertificateArn())
                .defaultActions(ListenerDefaultActionArgs.builder()
                        .targetGroupArn(tg.arn())
                        .type("forward")
                        .build())
                .loadBalancerArn(alb.arn())
                .port(443)
                .protocol("HTTPS")
                .tags(App.TAGS)
                .build());
    }
@full-art-3978
f

full-art-3978

03/12/2024, 10:14 PM
Hi!
a

adamant-lawyer-19698

03/13/2024, 9:38 AM
did it work? @full-art-3978