it would be nice to see a “outputs best practices”...
# python
s
it would be nice to see a “outputs best practices” document. with all the recent chatter about this i’m guessing this is (hopefully!) on their radar
b
yeah, it would be good indeed....
I ended up with this code... It's not python anymore 😞
s
you might be able to use
Output.all()
there
would make it only one apply call
b
it is only 1 apply just in that apply it has 2 internal function... but yes, I get your point
I might put this 2 functions somewhere else and assign global variable to it
s
You can also do this outside the resource definition which likely lead to cleaner code
☝️ 1
f
We recently put together a short video on inputs and outputs:

https://www.youtube.com/watch?v=lybOxul2otM

b
@stocky-spoon-28903 that did not work for me... the string was
<http://foo>.<Output
and it worked only when I put it in resource... I was getting errors from GCP for invalid strings 😞
s
@bland-lamp-16797 can you paste that line? This sounds like a slightly different variant of what I meant!
b
hmmm, ex: this works
Copy code
gcp_bucket_admin = gcp_storage.Bucket(
    resource_name='admin-b81-react-web',
    name=top_domain.apply(lambda c: str(f"admin.{env_name}.{c}")),
this does not:
Copy code
somevar = top_domain.apply(lambda c: str(f"admin.{env_name}.{c}")), 
gcp_bucket_admin = gcp_storage.Bucket(
    resource_name='admin-b81-react-web',
    name= somevar,
right now, whole definition looks like this
Copy code
gcp_bucket_admin = gcp_storage.Bucket(
    resource_name='admin-b81-react-web',
    name=top_domain.apply(lambda c: str(f"admin.{env_name}.{c}")),
    location="EUROPE-WEST3",  # EU
    force_destroy=True,
    bucket_policy_only=True,
    website={
        "mainPageSuffix": 'index.html',
        "notFoundPage": "404.html"
    },
    cors=[{
        "origin": [top_domain.apply(
            lambda c: str(f"<http://admin>.{env_name}.{c}"))],
        "method": ["GET", "HEAD", "PUT", "POST", "DELETE"],
        "response_header": ["*"],
        "max_age_seconds": 3600,
    }],
    project=get_project_id_by_env(env_name)
   )
s
I’ll take a look when I can put it on a bigger screen, phones are not kind to python code!