Skip to content

Commit

Permalink
Prepare v2.9.3 release (#123)
Browse files Browse the repository at this point in the history
Co-authored-by: Lucy Voigt <[email protected]>
  • Loading branch information
lucywyman and Lucy Voigt authored Oct 3, 2022
1 parent 29026a1 commit e6ad3ab
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 9 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## [2.9.3] (October 3, 2022)

BUG FIXES:

- Correctly set bucketBy to nil when explicitly set to an empty string to avoid API errors [#120](https://github.com/launchdarkly/terraform-provider-launchdarkly/issues/120)
- Print error message from API response for Teams resource

NOTES:

- Add `ignore_changes` guide

## [2.9.2] (September 1, 2022)

BUG FIXES:
Expand Down
6 changes: 3 additions & 3 deletions launchdarkly/fallthrough_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ func fallthroughFromResourceData(d *schema.ResourceData) (fallthroughModel, erro
fall := f[0].(map[string]interface{})
if isPercentRollout(f) {
rollout := fallthroughModel{Rollout: rolloutFromResourceData(fall[ROLLOUT_WEIGHTS])}
bucketBy, ok := fall[BUCKET_BY]
if ok {
rollout.Rollout.BucketBy = ldapi.PtrString(bucketBy.(string))
bucketBy := fall[BUCKET_BY].(string)
if bucketBy != "" {
rollout.Rollout.BucketBy = &bucketBy
}
return rollout, nil

Expand Down
6 changes: 3 additions & 3 deletions launchdarkly/resource_launchdarkly_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func resourceTeamCreate(ctx context.Context, d *schema.ResourceData, metaRaw int
_, _, err := client.ld.TeamsApi.PostTeam(client.ctx).TeamPostInput(teamBody).Execute()

if err != nil {
return diag.Errorf("Error when calling `TeamsApi.PostTeam`: %v\n\n request: %v", err, teamBody)
return diag.Errorf("Error when creating team %q: %s\n", key, handleLdapiErr(err))
}
d.SetId(key)

Expand All @@ -177,7 +177,7 @@ func resourceTeamRead(ctx context.Context, d *schema.ResourceData, metaRaw inter
}

if err != nil {
return diag.Errorf("failed to get team %q: %v", teamKey, err)
return diag.Errorf("failed to get team %q: %s", teamKey, handleLdapiErr(err))
}

members := make([]ldapi.Member, 0)
Expand All @@ -199,7 +199,7 @@ func resourceTeamRead(ctx context.Context, d *schema.ResourceData, metaRaw inter
}

if err != nil {
return diag.Errorf("failed to get members for team %q: %v", teamKey, err)
return diag.Errorf("failed to get members for team %q: %s", teamKey, handleLdapiErr(err))
}

members = append(members, memberResponse.Items...)
Expand Down
3 changes: 2 additions & 1 deletion launchdarkly/rule_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ func ruleFromResourceData(val interface{}) (rule, error) {
}
r.Clauses = append(r.Clauses, clause)
}
bucketBy, bucketByFound := ruleMap["bucket_by"].(string)
bucketBy := ruleMap["bucket_by"].(string)
bucketByFound := bucketBy != ""
if len(rolloutFromResourceData(ruleMap[ROLLOUT_WEIGHTS]).Variations) > 0 {
r.Rollout = rolloutFromResourceData(ruleMap[ROLLOUT_WEIGHTS])
if bucketByFound {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/flag_trigger.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: "launchdarkly"
page_title: "LaunchDarkly: launchdarkly_flag_trigger"
description: |-
Get information about LaunchDarkly flag trigers.
Get information about LaunchDarkly flag triggers.
---

# launchdarkly_flag_trigger
Expand Down
65 changes: 65 additions & 0 deletions website/docs/g/use_ignore_changes.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
layout: "launchdarkly"
page_title: "LaunchDarkly: Use ignore_changes to create resources with Terraform and update them in the UI"
description: |-
This guide covers
---

# Using `ignore_changes`

This guide explains when and how to use [ignore_changes lifecycle metadata](https://www.terraform.io/language/meta-arguments/lifecycle#ignore_changes) to avoid having Terraform try to update resources that were modified.

## When to use `ignore_changes`

### Use Terraform to create a resource in LaunchDarkly, and manage the resource through the UI

For example, you might provision teams in LaunchDarkly using Terraform, then allow team members to add new members to the team in the UI without needing to udpate Terraform. This is a case where you simply want to *create* the team using Terraform, but then manage the team for the rest of it's lifecycle through the UI. In order to continue managing the team using Terraform you would need to manually update your manifest to reflect the current state of the team, and then apply.

```
data "launchdarkly_team_member" "spongebob" {
email = "[email protected]"
}
resource "launchdarkly_team" "krusty_krab_staff" {
key = "krusty_krab_staff"
name = "Krusty Krab staff"
description = "Team serving Krabby patties"
members = [data.launchdarkly_team_member.spongebob.id]
lifecycle {
ignore_changes = [member_ids]
}
}
```

### When a resource is modified as a side-effect of other actions in LaunchDarkly

Sometimes resources in LaunchDarkly are modified as a side-effect of other actions in LaunchDarkly. For example, if you create an experiment using a flag, and then try to apply a Terraform manifest that manages that flag, it will fail. As a workaround for this you can use `ignore_changes` to tell Terraform to not try to update the modified resources.

```
resource "launchdarkly_feature_flag" "example" {
project_key = launchdarkly_project.example.key
key = "example-flag"
name = "Example flag"
description = "This demonstrates using ignore_changes"
variation_type = "boolean"
variations {
value = "true"
name = "True"
}
variations {
value = "false"
name = "False"
}
defaults {
on_variation = 1
off_variation = 0
}
lifecycle {
ignore_changes = [all]
}
}
```
4 changes: 3 additions & 1 deletion website/docs/r/project.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,6 @@ resource "launchdarkly_project" "example" {
}
```

Managing environment resources with Terraform should always be done on the project unless the project is not also managed with Terraform.
**Note:** Following an import, the first apply may show a diff in the order of your environments as Terraform realigns its state with the order of configurations in your project configuration. This will not change your environments or their SDK keys.

**Managing environment resources with Terraform should always be done on the project unless the project is not also managed with Terraform.**

0 comments on commit e6ad3ab

Please sign in to comment.