square-dress-80180
03/24/2021, 10:19 PMdb_user = os.environ['DB_USER']
# Create Output[Mapping] for use with args[Input[Mapping[str,str]]]
gatheredDBOutput = pulumi.Output.all(
db_host_address,
db_host_port,
db_name
)
def createBuildArgs(host_address, host_port, name, user):
return json.dumps({
"db_host_address": host_address,
"db_host_port": host_port,
"db_name": name,
"db_user": user,
})
buildArgs = gatheredDBOutput.apply(lambda args:
createBuildArgs(args[0], args[1], args[2], db_user)
)
flask_image = docker.Image("flask-dockerimage",
image_name=app_ecr_repo_repository_url,
build=docker.DockerBuild(
context="./frontend",
args=buildArgs
),
skip_push=False,
registry=app_registry
)
red-match-15116
03/24/2021, 11:53 PMargs
flask_image = docker.Image("flask-dockerimage",
image_name=app_ecr_repo_repository_url,
build=docker.DockerBuild(
context="./frontend",
args={
"db_host_address": db_host_address,
"db_host_port": db_host_port,
"db_name": db_name,
"db_user": db_user,
}
),
skip_push=False,
registry=app_registry
)
square-dress-80180
03/25/2021, 2:27 AMapply
statement in order to get things to work. It wasn’t accepting the Outputs within the dict directly.red-match-15116
03/25/2021, 2:43 AMapply
- because of the unexpected behavior related to preview
and the resource graph not being calculated correctly. There’s generally a way to refactor the code so that creating the resource within an apply is not necessary.