helpful-receptionist-73337
03/21/2023, 9:47 PMsecret_string
param i am using an apply
function to transform the Output. The issue i am having is that event though the secret is dependent on the private link, the apply
runs before the privatelink finishes causing my build to error out. Does anyone know how to make the apply wait until a resource is finished being created?
Here is a mock code snippet to help with context:
aws_endpoint_service = aws.ec2.VpcEndpoint(
f"{environment}-aws-vpc-endpoint",
vpc_id=vpc_configs["vpc_id"],
service_name=mongo_private_link_endpoint.endpoint_service_name,
vpc_endpoint_type="Interface",
subnet_ids=vpc_configs["subnet_ids"],
security_group_ids=vpc_configs["security_group_ids"],
)
mongo_private_link_endpoint_service = mongodbatlas.PrivateLinkEndpointService(
f"{environment}-PrivateLinkEndpointService",
project_id=mongo_private_link_endpoint.project_id,
private_link_id=mongo_private_link_endpoint.private_link_id,
endpoint_service_id=aws_endpoint_service.id,
provider_name="AWS",
)
cluster = mongodbatlas.get_cluster(
name=mongo_configs["cluster_name"], project_id=mongo_configs["project_id"]
)
secret = aws.secretsmanager.Secret(
resource_name=f"{environment}_mongo_connections",
name=f"{environment}_mongo_connections",
opts=ResourceOptions(delete_before_replace=True),
recovery_window_in_days=0,
)
secret_version = aws.secretsmanager.SecretVersion(
resource_name=f"{environment}_mongo_connections",
secret_id=secret.arn,
# the id does not exist until the endpoint service is created
# but the apply runs before it finishes causing a failure
secret_string=cluster.connection_strings.apply(
lambda x: json.dumps({"private_connection": f"{x[0].get(mongo_private_link_endpoint_service.id).split('://')[1]}"}
)
),
opts=ResourceOptions(depends_on=[mongo_private_link_endpoint_service]),
)
little-cartoon-10569
03/21/2023, 9:56 PMpulumi.all()
, which resolves multiple outputs at once?helpful-receptionist-73337
03/21/2023, 9:58 PMlittle-cartoon-10569
03/21/2023, 9:58 PMsecret_string=cluster.connection_strings.apply(
lambda x: json.dumps({"private_connection": f"{x[0].get(mongo_private_link_endpoint_service.id).split('://')[1]}"}
)
),
mongo_private_link_endpoint_service.id
too.helpful-receptionist-73337
03/21/2023, 10:03 PMsecret_string=Output.all(
cluster.connection_strings,
mongo_private_link_endpoint_service.interface_endpoint_id,
).apply(
lambda x:
json.dumps({
"private_connection": f"{x[0].get(x[1]).split('://')[1]}"
})
)
little-cartoon-10569
03/21/2023, 10:06 PMhelpful-receptionist-73337
03/21/2023, 10:09 PMlittle-cartoon-10569
03/21/2023, 10:11 PMhelpful-receptionist-73337
03/21/2023, 10:11 PM