diff --git a/.changelog/35150.txt b/.changelog/35150.txt new file mode 100644 index 000000000000..127f0d056502 --- /dev/null +++ b/.changelog/35150.txt @@ -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 +``` diff --git a/internal/service/datasync/agent.go b/internal/service/datasync/agent.go index 2725d9c6f63a..201f4d73a4c2 100644 --- a/internal/service/datasync/agent.go +++ b/internal/service/datasync/agent.go @@ -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, @@ -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