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

[datadog_integration_aws] EXTERNAL_ID environment variable is now optional for import #2788

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions datadog/resource_datadog_integration_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@ func resourceDatadogIntegrationAwsImport(ctx context.Context, d *schema.Resource
if d.Id() == "" {
return nil, fmt.Errorf("error importing aws integration resource. Resource with id `%s` does not exist", originalId)
}

d.Set("external_id", os.Getenv("EXTERNAL_ID"))
if v, ok := os.LookupEnv("EXTERNAL_ID"); ok {
d.Set("external_id", v)
}
return []*schema.ResourceData{d}, nil
}
8 changes: 7 additions & 1 deletion docs/resources/integration_aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ resource "datadog_integration_aws" "sandbox" {
Import is supported using the following syntax:

```shell
# Amazon Web Services integrations can be imported using their account ID and role name separated with a colon (:), while the external_id should be passed by setting an environment variable called EXTERNAL_ID
# Amazon Web Services integrations can be imported using their account ID and role name separated with a colon (:),
# The EXTERNAL_ID variable is optional and allows to set external_id

# Import will be done and the external_id will be set to the value of the EXTERNAL_ID variable
EXTERNAL_ID=${external_id} terraform import datadog_integration_aws.test ${account_id}:${role_name}

# Import will be done and the external_id will not be set
terraform import datadog_integration_aws.test ${account_id}:${role_name}
```
8 changes: 7 additions & 1 deletion examples/resources/datadog_integration_aws/import.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# Amazon Web Services integrations can be imported using their account ID and role name separated with a colon (:), while the external_id should be passed by setting an environment variable called EXTERNAL_ID
# Amazon Web Services integrations can be imported using their account ID and role name separated with a colon (:),
# The EXTERNAL_ID variable is optional and allows to set external_id

# Import will be done and the external_id will be set to the value of the EXTERNAL_ID variable
EXTERNAL_ID=${external_id} terraform import datadog_integration_aws.test ${account_id}:${role_name}

# Import will be done and the external_id will not be set
terraform import datadog_integration_aws.test ${account_id}:${role_name}
Loading