-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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 IAM certificates get deleted on rerun even though tf files were not changed #3837
Comments
attached https://github.com/avinci/terraform-repro I realized this is happening to even simple security groups. I am not sure what I might be doing wrong here for the NATSG. It keeps re doing SG. This is happening for ELBs with certs too and of course its happening for IAM certs and I did not want to upload my certs to repro that. |
I think the main issue is the fact that the diff code is not working as expected between whats on AWS and whats in the tfstate. |
I did another quick test. I made a change directly onto AWS SG and ran Based on this, I am doing something really wrong or the state comparison has some issues. |
I think I figured out the issue here about SGs getting updated. Not sure if its a bug or not...but for sure its weird as plan does not throw any error but keeps repeating the ops does not work
works
I will play with the certs now and see whats the issue and update a sample |
I added the repro for certificate issue now and the repo has been updated minus the keys I ran terraform apply 3 times
|
I think I figured out the bug. Our certs are chained and hence have the certificate authority information too. I think the diff is not working for the length of the string. Our certs structure is
they are chained together and the length of the file must be causing issues. |
+1 I'm having the same issue with certs being deleted/re-created on re-run despite no change. I'm loading the certs from a file. |
It appears that AWS likes to do some pre-processing on certs before installing them.
Pulling the chain out manually and specifying |
Can confirm this still happens on 0.6.8. The workaround mentioned by @gbarboza did fix it for us too. |
We had same issue with DigiCert certificates, so we had to update them ourself before pushing to Terraform & AWS:
|
I am specifying I am loading both from a file. The |
@jmstone617 Did you make sure that the files are using UNIX line breaks? Most CA's I've encountered don't issue files in that format. Use the command antonbabenko provided above or the |
I didn't. @antonbabenko's fix seems to work -- would be good to include this somewhere in the docs. |
AWS does some funky stuff to handle all the variations in certificates that CA's like to hand out to users. This commit adds a note about this and details how to avoid issues. See hashicorp#3837 for more information.
FWIW, antonbabenko's fix does indeed remove the error, but I get an SSL validation error when trying to hit my ELB. Using the original certificate from the CA resolves properly, but presents the TF error. So, I would guess that the .crt file itself is formatted properly, since AWS is accepting it. |
I'm not sure what else could be wrong? Here's a gist of the plan. I'm targeting a route53 resource for reference. Edit: |
got mine working - it was not the end of lines but the line length in one of the intermediate certs. Just do thx to the tip of @RykHawthorn |
Closed via #8074 |
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. |
I have 2 certs for SSL pointing to a 2 load balancers on AWS. Upon the first run of the terraform apply, it works fine. Now if I rerun apply again and not changing any part of the tf files, it will try to delete the IAM certs and this will fail as LBs are using it. Here is the log with TF_LOG enabled
Cert is present in the state file.
The text was updated successfully, but these errors were encountered: