GoogleCloudPlatform / deploymentmanager-samples

Deployment Manager samples and templates.
Apache License 2.0
939 stars 717 forks source link

Network template to support project parameter as one of the configurable elements #483

Closed vital4ik closed 5 years ago

vital4ik commented 5 years ago

Currently there is no way to specify the project in the template or the yaml. when using the template, networks are created in the DM creator project instead of the project that is being created. the option to provide the project as a parameter is not really working when this template is in a sequence of other templates used to create and configure brand new project.

ocsig commented 5 years ago

Thank you for your feedback!

(Please note, this is the dm-cft-dev branch, which is currently under development. This should be promoted to master within weeks.)

Feel free to let me know if you have any further question.

vital4ik commented 5 years ago

Hi, my current issue is that when i create a project and then in the sample template i try to create a VPC, there is no way for me to control what project the VPC is being created in. I cant use --project=project with the CFT command as all values including constructing the project name are dynamic within one global template that sets everything up in the project after its created. other templates like iam_member support providing project name so it is created in the correct project but network template does not seem to have the concept of the project.

vital4ik commented 5 years ago

here is an example of what I am trying to achieve: `{%- set id_prefix = "{}-{}-{}".format( properties.get("company", "NA") , properties.get("name", "NA") , properties.get("env", "NA") ) -%} {%- set location_prefix1 = "{}-{}".format( id_prefix , properties.get("region1", "NA") ) -%} {%- set location_prefix2 = "{}-{}".format( id_prefix , properties.get("region2", "NA") ) -%} resources:

ocsig commented 5 years ago

I highly recommend to create resources in deployments which are in the same project where the resource itself. I see benefits of avoiding cross project deployments. One advantage is you can use --project (or the CTF cli project property in the yaml.) It also gives you greater separation of duties via IAM.

If you really wish to stick to cross project deployments, the dev branch implements it for most of the resources: https://github.com/GoogleCloudPlatform/cloud-foundation-toolkit/tree/cft-dm-dev/dm/templates/network ( keep in mind, some templates like cloudFunctions does not support cross project deployments.)