no matter what I seem to do I just get this warn...
# general
a
no matter what I seem to do I just get this warning: payload is ------ [{‘name’: ‘pulumi-test-app’, ‘image’: ‘nginx’, ‘portMappings’: [{‘containerPort’: 80, ‘hostPort’: 80, ‘protocol’: ‘tcp’}], ‘secrets’: [{‘name’: ‘dbpassword’, ‘valueFrom’: {<pulumi.output.Output object at 0x109bbc400>}}]}]
b
can you share the full code?
a
sure
Copy code
db_password_ssm = pulumi.Config().require_secret('dbpassword')
db_password = aws.ssm.Parameter("pulumi-db-secret",
   type =  "SecureString",
   value = db_password_ssm)


pulumi.warn(db_password.translate_output_property("dp"))
task_def_payload = [{
      'name': 'pulumi-test-app',
      'image': 'nginx',
      'portMappings': [{
         'containerPort': 80,
         'hostPort': 80,
         'protocol': 'tcp'
      }],
      'secrets': [{ 'name': "dbpassword", 'valueFrom': {db_password.arn.apply(lambda a : a[0]['arn'])}}],

   }]

pulumi.warn(f"payload is ------ {task_def_payload}")
## simple ecs task definition


task_definition = aws.ecs.TaskDefinition('pulumi-app-task',
    family='fargate-task-definition',
    cpu='256',
    memory='512',
    network_mode='awsvpc',
   tags = global_tags,
    requires_compatibilities=['FARGATE'],
    execution_role_arn=role.arn,
    container_definitions=json.dumps(task_def_payload), opts=ResourceOptions(depends_on=[db_password])
)
b
okay, your apply is in the wrong place
should be something like this:
the apply should wrap your string
a
ahh ok so the apply should generate the whole json payload?
b
exactly yeah, if you think of it this way: "once the db password from the resource has finished, then build the JSON string" everything inside the apply happens after the db_password.arn has resolved: https://www.leebriggs.co.uk/blog/2021/05/09/pulumi-apply.html
a
great thank you 😄
that works
Copy code
task_def_payload = pulumi.Output.all('db_password.arn').apply(lambda arn : json.dumps(
 [{
		'name': 'pulumi-test-app',
		'image': 'nginx',
		'portMappings': [{
			'containerPort': 80,
			'hostPort': 80,
			'protocol': 'tcp'
		}],
		'secrets': [{ 'name': "dbpassword", 'valueFrom': arn[0]}],

	}]))
makes sense now 😄