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

aws_cloudwatch_log_group w/ retention_in_days set results in no arn #6169

Closed
mdxp opened this issue Apr 13, 2016 · 5 comments · Fixed by #6384
Closed

aws_cloudwatch_log_group w/ retention_in_days set results in no arn #6169

mdxp opened this issue Apr 13, 2016 · 5 comments · Fixed by #6384
Assignees

Comments

@mdxp
Copy link

mdxp commented Apr 13, 2016

When using retention_in_days set on a cloudwatch log group, the arn is not added to the state. If no retention is set this works as expected. This causes problems (failures like above) if trying to use the resulting log group:

* Resource 'aws_cloudwatch_log_group.test' does not have attribute 'arn' for variable 'aws_cloudwatch_log_group.test.arn'

Terraform Version

Terraform v0.6.14

Affected Resource(s)

  • aws_cloudwatch_log_group

Terraform Configuration Files

resource "aws_cloudwatch_log_group" "test" {
  name = "test"
  retention_in_days = 7
}

tfstate

"resources": {
                "aws_cloudwatch_log_group.cloudtrail": {
                    "type": "aws_cloudwatch_log_group",
                    "primary": {
                        "id": "test",
                        "attributes": {
                            "id": "test",
                            "name": "test",
                            "retention_in_days": "7"
                        }
                    }
                }
            }

The state is missing the arn and assuming that is referenced by any other resource it will obviously fail. On the second run (refresh) it will update it and add the arn to the state and work successfully. Verified and without the retention_in_days defined this woks fine.

The arn looks like: "arn": "arn:aws:logs:us-east-1:XXX:log-group:test:*",

@stack72
Copy link
Contributor

stack72 commented Apr 22, 2016

@mdxp

Well this is a great find. I was able to recreate this perfectly with the following config:

resource "aws_cloudwatch_log_group" "test" {
  name = "test"
  retention_in_days = 7
}

output "arn" {
    value = "${aws_cloudwatch_log_group.test.arn}"
}

Terraform apply gave the following:

terraform apply
aws_cloudwatch_log_group.test: Creating...
  arn:               "" => "<computed>"
  name:              "" => "test"
  retention_in_days: "" => "7"
aws_cloudwatch_log_group.test: Creation complete

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

The state of your infrastructure has been saved to the path
below. This state is required to modify and destroy your
infrastructure, so keep it safe. To inspect the complete state
use the `terraform show` command.

State path: terraform.tfstate

As you can see, no output:

terraform output
The state file has no outputs defined. Define an output
in your configuration with the `output` directive and re-run
`terraform apply` for it to become available.

on refreshing the state, I was able to get the output:

terraform plan
Refreshing Terraform state prior to plan...

aws_cloudwatch_log_group.test: Refreshing state... (ID: test)

No changes. Infrastructure is up-to-date. This means that Terraform
could not detect any differences between your configuration and
the real physical resources that exist. As a result, Terraform
doesn't need to do anything.
a % terraform output
arn = arn:aws:logs:us-west-2:xxxxx:log-group:test:*

@stack72
Copy link
Contributor

stack72 commented Apr 22, 2016

This means there is a missing state check on this somewhere... I will raise this with AWS now

aws/aws-sdk-go#650

@stack72 stack72 self-assigned this Apr 22, 2016
stack72 added a commit that referenced this issue Apr 27, 2016
Fixes #6169

The Update func was hitting a return err and when the err was empty, it
was skipping over the subsequent read func
@stack72
Copy link
Contributor

stack72 commented Apr 27, 2016

Hi @mdxp

I finally found the issue here :) PR has been submitted to fix it!

P.

@mdxp
Copy link
Author

mdxp commented Apr 27, 2016

Awesome; many thanks! looking forward to test it out.

stack72 added a commit that referenced this issue Apr 27, 2016
…6384)

Fixes #6169

The Update func was hitting a return err and when the err was empty, it
was skipping over the subsequent read func
xsellier pushed a commit to xsellier/terraform that referenced this issue May 17, 2016
…ashicorp#6384)

Fixes hashicorp#6169

The Update func was hitting a return err and when the err was empty, it
was skipping over the subsequent read func
@ghost
Copy link

ghost commented Apr 26, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants