[openstack-dev] [Heat] Referencing VPC resources across templates

Zane Bitter zbitter at redhat.com
Wed Apr 3 23:21:13 UTC 2013


On 03/04/13 23:40, Steve Baker wrote:
> On 04/03/2013 08:29 PM, Simon Pasquier wrote:
>> Hi,
>>
>> Let say I have a first template to create a VPC network and another
>> one to create a subnet associated to that VPC.
>>
>> First template:
>> {
>>    "AWSTemplateFormatVersion" : "2010-09-09",
>>    "Resources" : {
>>       "myVPC" : {
>>          "Type" : "AWS::EC2::VPC",
>>          "Properties" : {
>>             "CidrBlock" : "20.0.0.0/16 <http://20.0.0.0/16>"
>>          }
>>       }
>>    },
>>    "Outputs" : {
>>     "VpcID" : {
>>       "Value" : { "Ref" : "myVPC" },
>>       "Description" : "Reference of the myVPC"
>>     }
>>    }
>> }
>>
>> Second template:
>> {
>>    "AWSTemplateFormatVersion" : "2010-09-09",
>>    "Parameters" : {
>>     "VpcId" : {
>>       "Type" : "String",
>>       "Description" : "VpcId of your existing Virtual Private Cloud (VPC)"
>>     }
>>    },
>>    "Resources" : {
>>     "mySubnet" : {
>>          "Type" : "AWS::EC2::Subnet",
>>          "Properties" : {
>>             "VpcId" : { "Ref" : "VpcId" },
>>             "CidrBlock" : "20.0.0.0/24 <http://20.0.0.0/24>",
>>             "AvailabilityZone" : "us-east-1a"
>>          }
>>       }
>>    },
>>    "Outputs" : {
>>     "SubnetId" : {
>>       "Value" : { "Ref" : "mySubnet" },
>>       "Description" : "Reference to mySubnet"
>>     }
>>    }
>> }
>>
>> I want to pass the VpcId value as a parameter to the second template
>> but the stack creation fails. Looking at the code, this use case
>> doesn't seem to be supported.
>> Am I right? If yes, is it something planned for a future release?
> What version of Heat are you running? There was actually a change
> released in grizzly-rc1 which addressed this issue:
> https://bugs.launchpad.net/heat/+bug/1142812
> https://review.openstack.org/#/c/23391/

The issue is that it's then looked up using stack.resource_by_refid(), 
which only looks at resources in the current stack:
https://github.com/openstack/heat/commit/63882b7bcbc55e411db26b4689f9cfe30d5a722b#L3R51

That's used to get the router_id from the VPC resource's metadata. What 
you need is to use the supplied ID (which is the network_id) directly so 
that you don't need to access the VPC resource at all. I have no idea if 
that's possible with Quantum.

cheers,
Zane.

>
> If this doesn't work for you could you raise a launchpad bug?
>
> cheers
>
>
>
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>




More information about the OpenStack-dev mailing list