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

Missing trail causes aws_cloudtrail to fail #5981

Closed
mschurenko opened this issue Apr 1, 2016 · 2 comments · Fixed by #6024
Closed

Missing trail causes aws_cloudtrail to fail #5981

mschurenko opened this issue Apr 1, 2016 · 2 comments · Fixed by #6024
Assignees

Comments

@mschurenko
Copy link

If I create a new trail using the aws_coudtrail resource and then manually delete it outside of terraform, this is what happens if I run 'terraform plan':

Refreshing Terraform state prior to plan...

aws_eip.nat_eip_us-west-2a: Refreshing state... (ID: eipalloc-29b6664d)
aws_iam_role.clodutrail_opsauto: Refreshing state... (ID: clodutrail_opsauto)
aws_iam_role.cross_account_powerusers: Refreshing state... (ID: cross_account_powerusers)
aws_s3_bucket.work-opsauto-cloudtrail: Refreshing state... (ID: work-opsauto-cloudtrail)
aws_key_pair.infra: Refreshing state... (ID: infra)
aws_iam_role.lambda_role: Refreshing state... (ID: cfn-policy-filter-role)
aws_vpc_dhcp_options.dhcp_options: Refreshing state... (ID: dopt-2666fc43)
aws_vpc.vpc: Refreshing state... (ID: vpc-4b7d8c2f)
aws_eip.nat_eip_us-west-2c: Refreshing state... (ID: eipalloc-50be6e34)
aws_iam_role.assume_dns: Refreshing state... (ID: assume_dns)
aws_eip.nat_eip_us-west-2b: Refreshing state... (ID: eipalloc-ebbb6b8f)
aws_iam_instance_profile.pritunl_profile: Refreshing state... (ID: pritunl_profile)
aws_iam_role_policy.assume_dns_policy: Refreshing state... (ID: assume_dns:assume_dns_policy)
aws_iam_role_policy.powerusers_access: Refreshing state... (ID: cross_account_powerusers:powerusers_access)
aws_cloudwatch_log_group.clodutrail_opsauto: Refreshing state... (ID: clodutrail_opsauto)
aws_iam_role_policy.clodutrail_opsauto_policy: Refreshing state... (ID: clodutrail_opsauto:clodutrail_opsauto_policy)
aws_iam_role_policy.lambda_policy: Refreshing state... (ID: cfn-policy-filter-role:cfn-policy-filter-policy)
aws_lambda_function.lambda_function: Refreshing state... (ID: cfn-policy-filter)
aws_security_group.pritunl: Refreshing state... (ID: sg-e47bf983)
aws_subnet.private_us-west-2a: Refreshing state... (ID: subnet-7bc53e1f)
aws_subnet.public_us-west-2a: Refreshing state... (ID: subnet-7ac53e1e)
aws_subnet.public_us-west-2b: Refreshing state... (ID: subnet-9fe1fde8)
aws_internet_gateway.igw: Refreshing state... (ID: igw-d02578b5)
aws_subnet.private_us-west-2b: Refreshing state... (ID: subnet-90e1fde7)
aws_vpc_dhcp_options_association.dhcp_ass: Refreshing state... (ID: dopt-2666fc43-vpc-4b7d8c2f)
aws_subnet.private_us-west-2c: Refreshing state... (ID: subnet-16d9f24f)
aws_security_group.internal: Refreshing state... (ID: sg-e57bf982)
aws_subnet.public_us-west-2c: Refreshing state... (ID: subnet-17d9f24e)
aws_nat_gateway.nat_gw_us-west-2b: Refreshing state... (ID: nat-0675d6170c107a761)
aws_route_table.public: Refreshing state... (ID: rtb-07b66163)
aws_security_group_rule.openvpn-udp: Refreshing state... (ID: sgrule-4225448119)
aws_security_group_rule.all: Refreshing state... (ID: sgrule-4142607151)
aws_security_group_rule.openvpn-tcp: Refreshing state... (ID: sgrule-2232736303)
aws_security_group_rule.all-out: Refreshing state... (ID: sgrule-4142615056)
aws_instance.pritunl: Refreshing state... (ID: i-9a02465d)
aws_nat_gateway.nat_gw_us-west-2a: Refreshing state... (ID: nat-005f348294e0d2c11)
aws_cloudtrail.main: Refreshing state... (ID: main)
aws_nat_gateway.nat_gw_us-west-2c: Refreshing state... (ID: nat-0d958cb84e17ff654)
aws_network_acl.public_nacl: Refreshing state... (ID: acl-a5b276c1)
aws_route_table_association.public_us-west-2a: Refreshing state... (ID: rtbassoc-4024bf24)
aws_route_table_association.public_us-west-2c: Refreshing state... (ID: rtbassoc-4724bf23)
aws_route_table_association.public_us-west-2b: Refreshing state... (ID: rtbassoc-4624bf22)
aws_route_table.private_us-west-2b: Refreshing state... (ID: rtb-adb661c9)
aws_route_table.private_us-west-2a: Refreshing state... (ID: rtb-f3b66197)
aws_route_table.private_us-west-2c: Refreshing state... (ID: rtb-c3b661a7)
aws_route_table_association.private_us-west-2b: Refreshing state... (ID: rtbassoc-d524bfb1)
aws_route_table_association.private_us-west-2a: Refreshing state... (ID: rtbassoc-1624bf72)
aws_cloudwatch_metric_alarm.pritunl_recovery: Refreshing state... (ID: pritunl instance recovery)
null_resource.ansible_run: Refreshing state... (ID: 2793737461754285738)
aws_network_acl.private_nacl: Refreshing state... (ID: acl-a4b276c0)
aws_route_table_association.private_us-west-2c: Refreshing state... (ID: rtbassoc-ec24bf88)
Error refreshing state: 1 error(s) occurred:

* aws_cloudtrail.main: No CloudTrail found, using name "main"

Shouldn't it try to recreate the missing resource? Here is what my template looks like:

{
    "resource": {
        "aws_iam_role": {
            "clodutrail_opsauto": {
                "assume_role_policy": "${file(\"cloudtrail_lnk/policies/assume_role_policy.json\")}",
                "name": "clodutrail_opsauto"
            }
        },
        "aws_cloudwatch_log_group": {
            "clodutrail_opsauto": {
                "depends_on": [
                    "aws_iam_role.clodutrail_opsauto"
                ],
                "name": "clodutrail_opsauto"
            }
        },
        "aws_iam_role_policy": {
            "clodutrail_opsauto_policy": {
                "policy": "${file(\"cloudtrail_lnk/policies/role_policy.json\")}",
                "role": "${aws_iam_role.clodutrail_opsauto.id}",
                "name": "clodutrail_opsauto_policy"
            }
        },
        "aws_s3_bucket": {
            "work-opsauto-cloudtrail": {
                "policy": "${file(\"cloudtrail_lnk/policies/s3_bucket.json\")}",
                "bucket": "work-opsauto-cloudtrail"
            }
        },
        "aws_cloudtrail": {
            "main": {
                "s3_bucket_name": "${aws_s3_bucket.work-opsauto-cloudtrail.id}",
                "cloud_watch_logs_group_arn": "${aws_cloudwatch_log_group.clodutrail_opsauto.arn}",
                "is_multi_region_trail": true,
                "name": "main",
                "cloud_watch_logs_role_arn": "${aws_iam_role.clodutrail_opsauto.arn}"
            }
        }
    }
}

Thanks

@catsby
Copy link
Contributor

catsby commented Apr 5, 2016

Patched in #6024 , thanks!

@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.

3 participants