-
Notifications
You must be signed in to change notification settings - Fork 7
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
Can't create FargateService #398
Comments
Thank you. We need to investigate why is this happening. Note to self: the relevant code in the provider: https://github.com/pulumi/pulumi-awsx/blob/5586b5776d22c437044f2e20b23a1768d786fb97/awsx/ecs/ec2Service.ts#L53 |
Glad I found this issue! I have a service definition like this: //> using scala "3.3.3"
//> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement
//> using dep "org.virtuslab::besom-core:0.2.2"
//> using dep "org.virtuslab::besom-aws:6.23.0-core.0.2"
//> using dep "org.virtuslab::besom-awsx:2.5.0-core.0.2"
//> using dep "com.lihaoyi::upickle::3.2.0"
import besom.*
import besom.api.aws, besom.api.awsx, awsx.ecr, awsx.lb, awsx.ecs
import besom.api.awsx.ecs.inputs.*
import besom.api.awsx.lb.ApplicationLoadBalancerArgs
import besom.api.aws.ecs.inputs.ServiceNetworkConfigurationArgs
import besom.api.aws.cloudwatch.LogGroupArgs
import besom.json.*
@main def main = Pulumi.run {
val repository =
ecr.Repository(
"sentiment-service-repo",
ecr.RepositoryArgs(forceDelete = true)
)
val image = ecr.Image(
"sentiment-service-image",
ecr.ImageArgs(
repositoryUrl = repository.url,
context = p"../app",
platform = "linux/amd64"
)
)
val vpc = awsx.ec2.Vpc("sentiment-service-vpc")
val loadBalancer = lb.ApplicationLoadBalancer(
"sentiment-service-lb",
ApplicationLoadBalancerArgs(subnetIds = vpc.publicSubnetIds)
)
val cluster = aws.ecs.Cluster("sentiment-service-cluster")
val logGroup =
aws.cloudwatch.LogGroup(
"sentiment-service-log-group",
LogGroupArgs(retentionInDays = 7, name = "sentiment-service-logs")
)
val service =
image.imageUri.flatMap: image =>
ecs.FargateService(
"sentiment-service-fargate",
ecs.FargateServiceArgs(
networkConfiguration = ServiceNetworkConfigurationArgs(
subnets = vpc.publicSubnetIds,
assignPublicIp = true,
securityGroups =
loadBalancer.defaultSecurityGroup.map(_.map(_.id)).map(_.toList)
),
cluster = cluster.arn,
taskDefinitionArgs = FargateServiceTaskDefinitionArgs(
containers = Map(
"sentiment-service" -> TaskDefinitionContainerDefinitionArgs(
image = image,
name = "sentiment-service",
cpu = 128,
memory = 512,
essential = true,
logConfiguration = TaskDefinitionLogConfigurationArgs(
logDriver = "awslogs",
options = JsObject(
"awslogs-group" -> JsString("log-group"),
"awslogs-region" -> JsString("us-east-1"),
"awslogs-stream-prefix" -> JsString("ecs")
)
),
/*portMappings = List(
TaskDefinitionPortMappingArgs(
targetGroup = loadBalancer.defaultTargetGroup
)
)*/
)
)
)
)
)
Stack(logGroup).exports(
image = image.imageUri,
service = service,
vpc = vpc.id,
cluster = cluster.id,
url = p"http://${loadBalancer.loadBalancer.dnsName}"
)
} And I get this exception IF I do any of the steps below:
Here are the things that trigger this error:
Now, I've only been using Pulumi for like 2 days, so I don't know if it's a semantics problem or what, but the exception is very confusing. Note that there's a pulumi-java issue: pulumi/pulumi-java#1325 and this awsx one pulumi/pulumi-awsx#820 aaaand I'm only now noticing that @pawelprazak is aware :D |
IIRC I've tried a couple of workarounds from both issues but neither of them worked with Besom. |
Hey, I think we have this fixed on current main (with some workarounds for upstream issues). We will cut a release soon. @pawelprazak can you take a look on this and advise if anything can be done to work around this issue on 0.2.2? Paweł has made a big refactoring in serde layer that brought us to be completely up to date with upstream Pulumi serde and this was done to fix this issue mostly. This change is however binary incompatible on core-providers edge so we have to release it as a part of 0.3.x. I think we should do this really fast, considering I found a nasty grpc memoization issue when writing post-Scalar blogpost (also already fixed). |
Hi @keynmol, thank you for the reproduction and I'm sorry you've stumbled upon this cursed issue :) What we know:
The key workaround was to use explicit The workarounds might work on the current P.s. I'm very curious if the |
Good to hear 👍 I'm doing this for a blogpost as well so can easily wait. I will try the workaround, and will excitedly wait for the 0.3.0 :) |
Actually it seems I was able to achieve what I wanted (I think, the architecture looks and works the way I wanted) by
.. 60 loadBalancers = List(
.. 61 ServiceLoadBalancerArgs(
.. 62 containerName = "sentiment-service",
.. 63 containerPort = 80,
.. 64 targetGroupArn = loadBalancer.defaultTargetGroup.arn
.. 65 )
.. 66 ), |
Btw you should not need to flatMap on imageUri property to use its value as an argument for another Args. Args are built in a way that allows them to consume both raw values and values wrapped in Outputs ( |
That's a gotcha coming from the elasticity of Pulumi that Scala's ease of use of flatMap sort of exacerbates. Compile warn should help push people to use this power only when really necessary. |
Glad to hear you were able to workaround the issues. Feel free to reach out if any more problems crop up. I'll leave this open until release of 0.3.0, but I'm afraid that the underlying issue appears to be upstream unfortunately. |
@lbialy WDYT, can we close this now that the 0.3.x was released? I think we've done what we could on our side and the main problem in this thread is upstream, in the |
It is an open problem that is not fixed. I think we should leave this as a lower priority bug report and check after a new release of pulumi/pulumi-eks (there has been a new one few hours ago - 2.5.2 btw but I don't expect it to fix this problem). |
When I try to create a FargateServiceArgs class the Error shows up and tells me that I must add
taskDefinition
ortaskDefinitionArgs
. Even when I addtaskDefinition
, error still shows up. Example:Dependencies:
Main class:
Stack trace:
Another example, the same result:
The text was updated successfully, but these errors were encountered: