Open pawelprazak opened 6 months ago
Thanks for reporting this @pawelprazak. I'm going to transfer this to pulumi-java as I think the fix probably lies there.
I believe this is the same issue: https://github.com/pulumi/pulumi-awsx/issues/820
What is interesting, is that doing this:
var tg = loadBalancer.defaultTargetGroup()
.apply(
t -> t.name().applyValue(
n -> TargetGroup.get(n, t.id(), null, null)
)
);
Results in the following error:
aws:lb:TargetGroup (lb-515c2c0):
error: Preview failed: diffing urn:pulumi:dev::karol-issue-2-java::aws:lb/targetGroup:TargetGroup::lb-515c2c0: Invalid Attribute Combination
Attribute "port" must be specified when "target_type" is "instance".
target_type
Not sure if this is related but I've noticed this while trying to find a workaround, and if it's related it could help pinpoint the exact cause.
found another problem while working on a workaround, this is a promising workaround:
var cluster = new Cluster("cluster");
var loadBalancer = new ApplicationLoadBalancer("lb");
var taskDef = new FargateTaskDefinition("app-task", FargateTaskDefinitionArgs.builder()
.containers(Map.of(
"test", TaskDefinitionContainerDefinitionArgs.builder()
.name("test")
.image("nginx:latest")
.cpu(256)
.memory(512)
.portMappings(
Output.of(loadBalancer.defaultTargetGroup().apply(t -> Output.of(List.of(
TaskDefinitionPortMappingArgs.builder()
.containerPort(80)
.targetGroup(t)
.build()
)))).apply(o -> o)
)
.build()
))
.build()
);
var service = new FargateService("app-service", FargateServiceArgs.builder()
.cluster(cluster.arn())
.assignPublicIp(true)
.taskDefinition(taskDef.taskDefinition().apply(TaskDefinition::arn))
.desiredCount(1)
.build(),
ComponentResourceOptions.builder()
.customTimeouts(CustomTimeouts.builder()
.create(Duration.ofMinutes(60))
.build()
)
.build()
);
but results in:
error: Running program [PID: 71677](/opt/homebrew/opt/sdkman-cli/libexec/candidates/java/current/bin/java -classpath /Users/pprazak/repos/karol-issue-2/karol-issue-2-java/.mvn/wrapper/maven-wrapper.jar -Dmaven.home=/Users/pprazak/repos/karol-issue-2 -Dmaven.multiModuleProjectDirectory=/Users/pprazak/repos/karol-issue-2/karol-issue-2-java org.apache.maven.wrapper.MavenWrapperMain -Dorg.slf4j.simpleLogger.defaultLogLevel=warn --no-transfer-progress compile exec:java) failed with an unhandled exception:
java.lang.UnsupportedOperationException: Convert [com.pulumi.aws.lb.TargetGroup.targetHealthStates]: Error converting 'java.util.Collections$UnmodifiableRandomAccessList' to 'TypeShape{type=interface java.util.List, parameters=[TypeShape{type=class 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)
... 10 more
But it looks lika separate issue in the serde implementation on the Java SDK side.
What happened?
The same Pulumi program that succeeds in TS fails in Java:
I believe this might be because TS (and all other SDKs use the new serializer path, the
keepOutputValues
(specialOutputValueSig
) and Java uses the old output serializer.We can also see this is Besom Scala SDK, that uses the old serializer.
Example
The failing Java program:
And the working TypeScript:
Output of
pulumi about
TypeScript
Java
Additional context
None.
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).