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

providers/aws: fix source_dest_check on instance creation #1021

Merged
merged 1 commit into from
Feb 23, 2015

Conversation

phinze
Copy link
Contributor

@phinze phinze commented Feb 21, 2015

The SourceDestCheck attribute can only be changed via
ModifyInstance, so the AWS instance resource's Create function calls
out to Update before it returns to take care of applying
source_dest_check properly.

The Update function originally guarded against unnecessary API calls
with GetOk, which worked fine until #993 when we changed the GetOk
semantics to no longer distinguish between "configured and zero-value"
and "not configured".

I attempted in #1003 to fix this by switching to HasChange for the
guard, but this does not work in the Create case.

I played around with a few different ideas, none of which worked:

(a) Setting Default: true on `source_dest_check' has no effect

(b) Setting Computed: true on source_dest_check' and adding ad.Set call in theReadfunction (which will initially set the value totrue`
after instance creation). I really thought I could get this to work,
but it results in the following:

d.Get('source_dest_check')       // true
d.HasChange('source_dest_check') // false
d.GetChange('source_dest_check') // old: false, new: false

I couldn't figure out a way of coherently dealing with that result, so I
ended up throwing up my hands and giving up on the guard altogether.
We'll call ModifyInstance more than we have to, but this at least
yields expected behavior for both Creates and Updates.

Fixes #1020

The `SourceDestCheck` attribute can only be changed via
`ModifyInstance`, so the AWS instance resource's `Create` function calls
out to `Update` before it returns to take care of applying
`source_dest_check` properly.

The `Update` function originally guarded against unnecessary API calls
with `GetOk`, which worked fine until #993 when we changed the `GetOk`
semantics to no longer distinguish between "configured and zero-value"
and "not configured".

I attempted in #1003 to fix this by switching to `HasChange` for the
guard, but this does not work in the `Create` case.

I played around with a few different ideas, none of which worked:

(a) Setting `Default: true` on `source_dest_check' has no effect

(b) Setting `Computed: true` on `source_dest_check' and adding a `d.Set`
    call in the `Read` function (which will initially set the value to `true`
    after instance creation). I really thought I could get this to work,
    but it results in the following:

```go
d.Get('source_dest_check')       // true
d.HasChange('source_dest_check') // false
d.GetChange('source_dest_check') // old: false, new: false
```

I couldn't figure out a way of coherently dealing with that result, so I
ended up throwing up my hands and giving up on the guard altogether.
We'll call `ModifyInstance` more than we have to, but this at least
yields expected behavior for both Creates and Updates.

Fixes #1020
@phinze
Copy link
Contributor Author

phinze commented Feb 21, 2015

This is a good example of the fallout of the GetOk semantics change. I think ResourceData should be able to support the provider better in scenarios like this. I'm going to have a think about this. 💭

cc @mitchellh to join me in said think

@mitchellh
Copy link
Contributor

Yeah... going to merge this LGTM. But yeah, I noticed this. Also, we should talk about doing a branch to backport a 0.3.8 out to fix this while we do 0.4.

mitchellh added a commit that referenced this pull request Feb 23, 2015
…eck-on-create

providers/aws: fix source_dest_check on instance creation
@mitchellh mitchellh merged commit 84b1db4 into master Feb 23, 2015
@mitchellh mitchellh deleted the b-aws-instance-source-dest-check-on-create branch February 23, 2015 21:45
@ghost
Copy link

ghost commented May 4, 2020

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.

@ghost ghost locked and limited conversation to collaborators May 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

source_dest_check broken in 0.3.7
2 participants