Skip to content

Commit

Permalink
Merge pull request #35150 from hashicorp/b-datasync-activation_key-im…
Browse files Browse the repository at this point in the history
…port

r/aws_datasync_agent: remove ExactlyOneOf activation_key, ip_address
  • Loading branch information
jar-b committed Jan 5, 2024
2 parents 2fa1e3b + d502fae commit d69974e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .changelog/35150.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_datasync_agent: Fix import of agents created with `activation_key` by removing requirement for one of `ip_address` or `activation_key` to be set
```
17 changes: 10 additions & 7 deletions internal/service/datasync/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,14 @@ func ResourceAgent() *schema.Resource {
Optional: true,
Computed: true,
ForceNew: true,
ExactlyOneOf: []string{"activation_key", "ip_address"},
ConflictsWith: []string{"private_link_endpoint"},
ConflictsWith: []string{"private_link_endpoint", "ip_address"},
},
"ip_address": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ExactlyOneOf: []string{"activation_key", "ip_address"},
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ConflictsWith: []string{"activation_key"},
},
"private_link_endpoint": {
Type: schema.TypeString,
Expand Down Expand Up @@ -107,6 +106,10 @@ func resourceAgentCreate(ctx context.Context, d *schema.ResourceData, meta inter

// Perform one time fetch of activation key from gateway IP address.
if activationKey == "" {
if agentIpAddress == "" {
return sdkdiag.AppendErrorf(diags, "one of activation_key or ip_address is required")
}

client := &http.Client{
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
Expand Down

0 comments on commit d69974e

Please sign in to comment.