https://pulumi.com logo
Title
a

ambitious-article-39970

07/05/2021, 3:22 PM
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

billowy-army-68599

07/05/2021, 3:23 PM
can you share the full code?
a

ambitious-article-39970

07/05/2021, 3:26 PM
sure
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

billowy-army-68599

07/05/2021, 3:36 PM
okay, your apply is in the wrong place
should be something like this:
the apply should wrap your string
a

ambitious-article-39970

07/05/2021, 3:42 PM
ahh ok so the apply should generate the whole json payload?
b

billowy-army-68599

07/05/2021, 3:44 PM
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

ambitious-article-39970

07/05/2021, 4:09 PM
great thank you 😄
that works
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 😄