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

resource/aws_app_cookie_stickiness_policy: Properly read lb_port into Terraform state and support resource import #7080

Merged
merged 1 commit into from
Jan 10, 2019
Merged
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
7 changes: 6 additions & 1 deletion aws/resource_aws_app_cookie_stickiness_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ func resourceAwsAppCookieStickinessPolicy() *schema.Resource {
Create: resourceAwsAppCookieStickinessPolicyCreate,
Read: resourceAwsAppCookieStickinessPolicyRead,
Delete: resourceAwsAppCookieStickinessPolicyDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},

Schema: map[string]*schema.Schema{
"name": {
Expand Down Expand Up @@ -136,7 +139,9 @@ func resourceAwsAppCookieStickinessPolicyRead(d *schema.ResourceData, meta inter
d.Set("cookie_name", cookieAttr.AttributeValue)
d.Set("name", policyName)
d.Set("load_balancer", lbName)
d.Set("lb_port", lbPort)

lbPortInt, _ := strconv.Atoi(lbPort)
d.Set("lb_port", lbPortInt)

return nil
}
Expand Down
5 changes: 5 additions & 0 deletions aws/resource_aws_app_cookie_stickiness_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ func TestAccAWSAppCookieStickinessPolicy_basic(t *testing.T) {
),
),
},
{
ResourceName: "aws_app_cookie_stickiness_policy.foo",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccAppCookieStickinessPolicyConfigUpdate(lbName),
Check: resource.ComposeTestCheckFunc(
Expand Down
8 changes: 8 additions & 0 deletions website/docs/r/app_cookie_stickiness_policy.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,11 @@ In addition to all arguments above, the following attributes are exported:
* `load_balancer` - The name of load balancer to which the policy is attached.
* `lb_port` - The load balancer port to which the policy is applied.
* `cookie_name` - The application cookie whose lifetime the ELB's cookie should follow.

## Import

Application cookie stickiness policies can be imported using the ELB name, port, and policy name separated by colons (`:`), e.g.

```sh
$ terraform import aws_app_cookie_stickiness_policy.example my-elb:80:my-policy
```