-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Add the auto_accept option for VpcPeeringConnection #1161
Conversation
} else { | ||
d.Set("accept_status", pc.Status.Code) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we try re-writing this so that resourceAwsVpcPeeringRead
is the only place we're calling d.Set("accept_status")
(at least in this context).
As is, a cursory glance shows setting accept_status
if auto_accept
is false
, simply b/c the other set is in another function.
Additionally, we ignore the error returned from resourceVpcPeeringConnectionAccept
here.
I'm thinking something like this:
[...]
// in resourceAwsVpcPeeringRead
code := pc.Status.Code
if v, ok := d.GetOk("auto_accept"); ok {
updatedCode, err := resourceVpcPeeringConnectionAccept(ec2conn, pc, d.Id());
if err!=nil {
// error handling
}
// set to new Status.code,
// or other handling
code = updatedCode
}
d.Set("accept_status", code)
// remainder of func
[...]
func resourceVpcPeeringConnectionAccept(conn *ec2.EC2, oldPc *ec2.VpcPeeringConnection, id string) (string, error) {
// [...]
// accepts string ID instead of resource
// returns string code, error
}
Or something to that effect..
Looks good so far, pending some nit-pick and questions |
Hey @julienba – thanks for the cleanups! Could you take a shot at rebasing this on Thanks again! |
Conflicts: builtin/providers/aws/resource_aws_vpc_peering_connection.go
I merged it. But I'm not sure of what I'm doing (go noobie here) with aws.StringValue, is that some kind of pointer ? |
Yeah, the The merge looks good, thanks! After further review though, I have to ask why the block of code that calls Assuming I understand correctly, the flow would then be:
|
You're right, it makes more sense that way. I doing it for avoiding to read Should I duplicate the call of |
I would make the change and move this idea to the In that function, I would use a As is, it looks like if your VPC peering connection isn't in that state on the first run, you never re-attempt |
Looking into the code more, I noticed that, if without hitting an error, the refresh func will always return a state of The AWS docs aren't terribly clear (from what I saw) as the the actual valid states, so I'm assuming the target state should really be our |
Yes it's |
Conflicts: builtin/providers/aws/resource_aws_vpc_peering_connection.go
aws-sdk-go don't use credential in .aws folder anymore |
Keep watching #1049 |
great ! |
Hello – sorry for the late catch-up here. Terraform and it's current aws-sdk-go library should pick up an credentials in |
LGTM just needs to be squashed |
or not squashed, but rebased |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Following the description of http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-AcceptVpcPeeringConnection.html