Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PeeringConnection: #416

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions lib/chef/provider/aws_vpc_peering_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ def create_aws_object

options = {}
options[:vpc_id] = new_resource.vpc
options[:peer_vpc_id] = new_resource.peer_vpc
options[:peer_owner_id] = new_resource.peer_owner_id unless new_resource.peer_owner_id.nil?
options = AWSResource.lookup_options(options, resource: new_resource)

if new_resource.peer_owner_id.nil?
options[:peer_vpc_id] = new_resource.peer_vpc
options = AWSResource.lookup_options(options, resource: new_resource)
else
options = AWSResource.lookup_options(options, resource: new_resource)
options[:peer_vpc_id] = new_resource.peer_vpc
options[:peer_owner_id] = new_resource.peer_owner_id
end

ec2_resource = new_resource.driver.ec2_resource
vpc = ec2_resource.vpc(options[:vpc_id])
Expand Down Expand Up @@ -56,8 +62,13 @@ def update_aws_object(vpc_peering_connection)
peer_owner_id = vpc_peering_connection.accepter_vpc_info.owner_id

desired_vpc_id = Chef::Resource::AwsVpc.get_aws_object_id(new_resource.vpc, resource: new_resource)
desired_peer_vpc_id = Chef::Resource::AwsVpc.get_aws_object_id(new_resource.peer_vpc, resource: new_resource)
desired_peer_owner_id = new_resource.peer_owner_id
if new_resource.peer_owner_id.nil?
desired_peer_owner_id = new_resource.peer_owner_id
desired_peer_vpc_id = Chef::Resource::AwsVpc.get_aws_object_id(new_resource.peer_vpc, resource: new_resource)
else
desired_peer_vpc_id = new_resource.peer_vpc
desired_peer_owner_id = new_resource.peer_owner_id
end

if desired_vpc_id && vpc_id != desired_vpc_id
raise "VCP peering connection requester vpc cannot be changed after being created! Desired requester vpc id for #{new_resource.name} (#{vpc_peering_connection.id}) was \"#{desired_vpc_id}\" and actual id is \"#{vpc_id}\""
Expand Down