sparse-caravan-37954
09/13/2023, 2:03 PMcontainer_properties = {
"jobRoleArn": batch_role.arn,
"command": [
'sh',
'-c',
'echo Ref::param1'
],
"image": image_uri,
"memory": 1024*2,
"vcpus": 1,
}
job_definition = aws.batch.JobDefinition("jobDefinition",
type="container",
container_properties=pulumi.Output.json_dumps(container_properties)
),
parameters={
"param1": "pippo",
},
)
When the job is run, however, the output is Ref::param1
instead of pippo
.
I think the problem is in the fact that the container properties definition contains pulumi Output objects (batch_role
and image_uri
are resources defined before in the full code) and therefore I need the pulumi.Output.json_dumps
story when using it in the job definition, and this is somehow avoiding the parameters to be picked up. Any idea? (edited)cuddly-nightfall-71097
09/13/2023, 2:06 PMpulumi.Output.json_dumps
(it's python, right?). It returns Output
and produces string when all keys and values for the dict are ready.pformat = pulumi.Output.format
to_json = pulumi.Output.json_dumps
container_definitions=to_json(
[
{
"name": service.container_name,
"image": pformat("{}:{}", image, service.image_tag),
"portMappings": [
{"containerPort": service.grpc_port},
{"containerPort": service.http_port},
],
"environment": environment,
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": log_group.name,
"awslogs-region": get_region().name,
"awslogs-stream-prefix": service.image_tag,
},
},
}
]
),
sparse-caravan-37954
09/13/2023, 2:12 PMpulumi.Output.json_dumps(container_properties)
, but the problem persists unfortunatelycuddly-nightfall-71097
09/13/2023, 2:14 PMRef::param1
so it is used literally. I didn't work with Batch 😞
I would try fixing it in web console, to make it working, then see what is the difference between web version and what Pulumi generates.sparse-caravan-37954
09/13/2023, 2:15 PMcuddly-nightfall-71097
09/13/2023, 2:17 PMsparse-caravan-37954
09/13/2023, 2:18 PMcontainer_properties = {
"jobRoleArn": batch_role.arn,
"command": [
'sh',
'-c',
'echo $VAR'
],
"environment": [
{"name": "VAR", "value": "Ref::param1"},
],
"image": image_uri,
"memory": 1024*2,
"vcpus": 1,
}
job_definition = aws.batch.JobDefinition("jobDefinition",
type="container",
container_properties=pulumi.Output.json_dumps(container_properties)
),
parameters={
"param1": "pippo",
},
)
but nothing, the value of VAR
is `Ref::param1"cuddly-nightfall-71097
09/13/2023, 2:29 PMecho
directly instead of sh -c
(since it's usually a program rather than shell alias).
like
["echo", "Ref::param1"]
sparse-caravan-37954
09/13/2023, 2:33 PMecho
command was just a simplification. In reality I have someting like sh -c python my_script.py --param Ref::param1
cuddly-nightfall-71097
09/13/2023, 5:16 PMsh
.