Created
July 7, 2021 00:53
-
-
Save karolzlot/0f59b99f950cbc3a6ce06e93110cc13a to your computer and use it in GitHub Desktop.
Pulumi + Python + Google Cloud Run -> version 1, with public access
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pulumi | |
import pulumi_gcp as gcp | |
region= "us-central1" | |
# Cloud Run Service is not enabled by default, let's enable it | |
enableCloudRun = gcp.projects.Service("EnableCloudRun", | |
service= "run.googleapis.com", | |
) | |
cloud_run_hello_service = gcp.cloudrun.Service("hello-service", | |
location=region, # Google Cloud Region | |
template=gcp.cloudrun.ServiceTemplateArgs( | |
spec=gcp.cloudrun.ServiceTemplateSpecArgs( | |
containers=[gcp.cloudrun.ServiceTemplateSpecContainerArgs( | |
image="us-docker.pkg.dev/cloudrun/container/hello", # "Hello-world" container | |
)], | |
), | |
), | |
traffics=[gcp.cloudrun.ServiceTrafficArgs( # this just sets traffic 100% to our app | |
latest_revision=True, | |
percent=100, | |
)], | |
opts=pulumi.ResourceOptions(depends_on=[enableCloudRun]) # this line tells Pulumi that Cloud Run service requires enabled Cloud Run API | |
) | |
pulumi.export("cloud_run_url", cloud_run_hello_service.statuses[0].url) | |
hello_service_iam_member = gcp.cloudrun.IamMember("hello_service_iam_member", | |
service= cloud_run_hello_service.name, | |
role= "roles/run.invoker", | |
member= "allUsers") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment