Last active
July 6, 2021 23:41
-
-
Save karolzlot/561941acf4239fee2c8a07c8d2fb3026 to your computer and use it in GitHub Desktop.
Pulumi + Python + Google Cloud Run -> version 1, without public access
This file contains 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment