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

Terraform cleanups #459

Merged
merged 8 commits into from
Aug 18, 2024
Merged

Terraform cleanups #459

merged 8 commits into from
Aug 18, 2024

Conversation

Mic92
Copy link
Member

@Mic92 Mic92 commented Aug 18, 2024

nix-shell-env % ./tf.sh plan

Initializing the backend...
Initializing modules...

Initializing provider plugins...
- Finding latest version of fastly/fastly...
- Finding latest version of aegirhealth/netlify...
- Finding latest version of numtide/secret...
- Finding latest version of hashicorp/aws...
- Installing fastly/fastly v5.7.1...
- Installed fastly/fastly v5.7.1 (unauthenticated)
- Installing aegirhealth/netlify v0.6.12...
- Installed aegirhealth/netlify v0.6.12 (unauthenticated)
- Installing numtide/secret v1.2.1...
- Installed numtide/secret v1.2.1 (unauthenticated)
- Installing hashicorp/aws v5.43.0...
- Installed hashicorp/aws v5.43.0 (unauthenticated)

OpenTofu has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that OpenTofu can guarantee to make the same selections by default when
you run "tofu init" in the future.

╷
│ Warning: Incomplete lock file information for providers
│
│ Due to your customized provider installation methods, OpenTofu was forced to calculate lock file checksums locally for the following providers:
│   - aegirhealth/netlify
│   - fastly/fastly
│   - hashicorp/aws
│   - numtide/secret
│
│ The current .terraform.lock.hcl file only includes checksums for linux_amd64, so OpenTofu running on another platform will fail to install these providers.
│
│ To calculate additional checksums for another platform, run:
│   tofu providers lock -platform=linux_amd64
│ (where linux_amd64 is the platform to generate)
╵

OpenTofu has been successfully initialized!

You may now begin working with OpenTofu. Try running "tofu plan" to see
any changes that are required for your infrastructure. All OpenTofu commands
should now work.

If you ever set or change modules or backend configuration for OpenTofu,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
aws_iam_user.s3-upload-releases: Refreshing state... [id=s3-upload-releases]
aws_iam_user.s3-upload-cache: Refreshing state... [id=s3-upload-cache]
module.fastlylogs.data.aws_iam_policy_document.assume_role_policy: Reading...
aws_iam_user.s3-upload-tarballs: Refreshing state... [id=s3-upload-tarballs]
aws_iam_user.fastly-cache-access: Refreshing state... [id=fastly-cache-access]
module.fastlylogs.data.aws_iam_policy_document.assume_role_policy: Read complete after 0s [id=3692727658]
module.fastlylogs.aws_s3_bucket.logs: Refreshing state... [id=fastly-logs-20220622145016462800000001]
module.fastlylogs.aws_iam_role.fastly_log_forwarder: Refreshing state... [id=FastlyLogForwarder]
aws_key_pair.edef: Refreshing state... [id=edef-key]
aws_iam_role.archeologist-worker: Refreshing state... [id=archeologist-worker]
aws_s3_bucket.archeologist: Refreshing state... [id=nix-archeologist]
aws_iam_access_key.fastly-cache-access: Refreshing state... [id=AKIARFORQIOYTUULUS2Z]
module.fastlylogs.aws_s3_bucket_policy.logs: Refreshing state... [id=fastly-logs-20220622145016462800000001]
module.fastlylogs.data.aws_iam_policy_document.fastly_write: Reading...
module.fastlylogs.data.aws_iam_policy_document.fastly_write: Read complete after 0s [id=3829673833]
module.fastlylogs.aws_iam_policy.policy: Refreshing state... [id=arn:aws:iam::080433136561:policy/system/FastlyLogForwarder20220622145111992500000001]
module.fastlylogs.aws_iam_role_policy_attachment.attachment: Refreshing state... [id=FastlyLogForwarder-20220622145113213800000002]
data.aws_iam_policy_document.archaeologist: Reading...
data.aws_iam_policy_document.archaeologist: Read complete after 0s [id=650203950]
aws_iam_policy.archologist: Refreshing state... [id=arn:aws:iam::080433136561:policy/archeologist]
aws_iam_role_policy.archeologist-worker: Refreshing state... [id=archeologist-worker:archeologist-worker]
aws_iam_instance_profile.archeologist: Refreshing state... [id=archeologist-worker]
aws_instance.archeologist: Refreshing state... [id=i-037c8169e6c66b0a0]

No changes. Your infrastructure matches the configuration.

OpenTofu has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
╷
│ Warning: Argument is deprecated
│
│   with module.fastlylogs.aws_s3_bucket.logs,
│   on fastlylog/main.tf line 1, in resource "aws_s3_bucket" "logs":
│    1: resource "aws_s3_bucket" "logs" {
│
│ Use the aws_s3_bucket_lifecycle_configuration resource instead
│
│ (and one more similar warning elsewhere)
╵
./tf.sh plan  3.59s user 0.86s system 46% cpu 9.562 total
nix-shell-env % plan
OpenTofu has been successfully initialized!

You may now begin working with OpenTofu. Try running "tofu plan" to see
any changes that are required for your infrastructure. All OpenTofu commands
should now work.

If you ever set or change modules or backend configuration for OpenTofu,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
data.terraform_remote_state.terraform-iam: Reading...
secret_resource.netlify_token: Refreshing state... [id=-]
netlify_dns_zone.nixos: Refreshing state... [id=5e6ce1b8b6f808aa16acd1ff]
netlify_deploy_key.key: Refreshing state... [id=5f57a0194c5ada3d6bbb2cd4]
netlify_site.nixos-search: Refreshing state... [id=14ea525c-8099-41d0-bfc6-522f822b9c9b]
netlify_site.nixos-common-styles: Refreshing state... [id=2896653a-1bc4-41c0-a544-f9cfbd1cb2e6]
netlify_site.nixos-status: Refreshing state... [id=3816fba8-b596-4d3b-8f6c-333a6f8d593f]
netlify_site.nixos-summer: Refreshing state... [id=4b18dc3c-e45f-4005-968b-b8bada01d145]
netlify_site.nix-dev: Refreshing state... [id=ce1457da-4d35-4d9e-ab99-fabd9ec28af1]
netlify_site.nixos-planet: Refreshing state... [id=cad7595d-5387-4f41-b676-c19e7c6ff7cd]
aws_s3_bucket.releases_inventory: Refreshing state... [id=nix-releases-inventory220231029182031496800000001]
aws_s3_bucket.releases: Refreshing state... [id=nix-releases]
netlify_site.nixos-homepage: Refreshing state... [id=c6758977-3023-44a9-b1f0-9665e1e38dd4]
netlify_dns_record.nixos_google_verification: Refreshing state... [id=6501bbfd62d55b105704b8dc]
aws_s3_bucket.nixpkgs-tarballs: Refreshing state... [id=nixpkgs-tarballs]
netlify_dns_record.nixos_MX1: Refreshing state... [id=615afb1057752009425f3372]
netlify_dns_record.nixos_MX2: Refreshing state... [id=615afb0f858de311013f51bb]
netlify_dns_record.nixos["mail._domainkey.wiki.nixos.org-TXT"]: Refreshing state... [id=65e8b040c55aad2d86caba58]
data.terraform_remote_state.terraform-iam: Read complete after 0s
netlify_dns_record.nixos["umbriel.nixos.org-A"]: Refreshing state... [id=6552aeb05ca68e3913eb4c4e]
netlify_dns_record.nixos["makemake.ngi.nixos.org-A"]: Refreshing state... [id=6635820a8606eb78a2b38c79]
netlify_dns_record.nixos["vault.nixos.org-CNAME"]: Refreshing state... [id=650aa90c14afff227e3abe11]
netlify_dns_record.nixos["grafana.nixos.org-CNAME"]: Refreshing state... [id=65da727105596c5375ae3839]
netlify_dns_record.nixos["tarballs.nixos.org-CNAME"]: Refreshing state... [id=615af9657a2e6509f770453c]
netlify_dns_record.nixos["eris.nixos.org-A"]: Refreshing state... [id=65a307994033460a9e1bef6c]
netlify_dns_record.nixos["eris.nixos.org-AAAA"]: Refreshing state... [id=65c94534bb96ae6c1383015b]
netlify_dns_record.nixos["survey.nixos.org-CNAME"]: Refreshing state... [id=669517093957410f7d1966ce]
netlify_dns_record.nixos["hydra.ngi0.nixos.org-CNAME"]: Refreshing state... [id=663b9737112232095a4d0b50]
netlify_dns_record.nixos["intense-heron.mac.nixos.org-A"]: Refreshing state... [id=6331b51fa26a890062420aa4]
netlify_dns_record.nixos["wiki.nixos.org-AAAA"]: Refreshing state... [id=65ca04d6cf29b6d779ea0ec5]
netlify_dns_record.nixos["maximum-snail.mac.nixos.org-A"]: Refreshing state... [id=6331b520d8826a007e597633]
netlify_dns_record.nixos["makemake.ngi.nixos.org-AAAA"]: Refreshing state... [id=6635820a4e766a716e38b250]
netlify_dns_record.nixos["matrix.nixos.org-CNAME"]: Refreshing state... [id=6645f01919d450a081f79522]
netlify_dns_record.nixos["_dmarc.caliban.nixos.org-TXT"]: Refreshing state... [id=665ecb6cc3578fd7f0b39399]
netlify_dns_record.nixos["_dmarc.discourse.nixos.org-TXT"]: Refreshing state... [id=618155b76637353d660bb73b]
netlify_dns_record.nixos["caliban.nixos.org-AAAA"]: Refreshing state... [id=65006a29dc5e9476a32ec8d7]
netlify_dns_record.nixos["discourse.nixos.org-AAAA"]: Refreshing state... [id=6181546fa0a3fffd5bd6dfcc]
netlify_dns_record.nixos["conf.nixos.org-CNAME"]: Refreshing state... [id=615af950858de30ba93f528a]
netlify_dns_record.nixos["releases.nixos.org-CNAME"]: Refreshing state... [id=615af99c33603c0965cacdfb]
netlify_dns_record.nixos["discourse.nixos.org-MX"]: Refreshing state... [id=6181546f213973263a4472b9]
netlify_dns_record.nixos["channels.nixos.org-CNAME"]: Refreshing state... [id=615af98d33603c099ccacab6]
netlify_dns_record.nixos["mail._domainkey.discourse.nixos.org-TXT"]: Refreshing state... [id=618155b7254bc3ff889e6d66]
netlify_dns_record.nixos["chat.nixos.org-CNAME"]: Refreshing state... [id=6645f018f9b1739d6ee572c0]
netlify_dns_record.nixos["_acme-challenge.tarballs.nixos.org-CNAME"]: Refreshing state... [id=615af8f35c46ae0f6db95f5a]
netlify_dns_record.nixos["haumea.nixos.org-AAAA"]: Refreshing state... [id=65a3135f3a151813bf59817b]
netlify_dns_record.nixos["sweeping-filly.mac.nixos.org-A"]: Refreshing state... [id=6331b51fa26a890074420c92]
netlify_dns_record.nixos["buildbot.ngi.nixos.org-CNAME"]: Refreshing state... [id=663b9737004dc005a6088ae0]
netlify_dns_record.nixos["discourse.nixos.org-A"]: Refreshing state... [id=6181546fe407fb12e1db70ac]
netlify_dns_record.nixos["prometheus.nixos.org-CNAME"]: Refreshing state... [id=65da7272fd55294c9dec9936]
netlify_dns_record.nixos["live.nixos.org-CNAME"]: Refreshing state... [id=666706b2b5c92b1af8c352db]
netlify_dns_record.nixos["caliban.nixos.org-A"]: Refreshing state... [id=65006a29dc5e94772c2ec88e]
netlify_dns_record.nixos["mobile.nixos.org-CNAME"]: Refreshing state... [id=615af950858de30a573f56c6]
netlify_dns_record.nixos["cache.ngi0.nixos.org-CNAME"]: Refreshing state... [id=615af8f231afdf14cf372641]
netlify_dns_record.nixos["rhea.nixos.org-A"]: Refreshing state... [id=6245af41610a70627d20daff]
netlify_dns_record.nixos["haumea.nixos.org-A"]: Refreshing state... [id=615af4806cb2840b73637bc1]
netlify_dns_record.nixos["_acme-challenge.channels.nixos.org-CNAME"]: Refreshing state... [id=615af8f333603c0e03cb2096]
netlify_dns_record.nixos["wiki.nixos.org-TXT"]: Refreshing state... [id=65e8b03f1454bb2c6376f554]
netlify_dns_record.nixos["enormous-catfish.mac.nixos.org-A"]: Refreshing state... [id=6331b51f325bc5008926d1fc]
netlify_dns_record.nixos["planet.nixos.org-CNAME"]: Refreshing state... [id=615b04f631afdf1dea3728f6]
netlify_dns_record.nixos["_github-challenge-nixos.nixos.org-TXT"]: Refreshing state... [id=615afae216335d0b82831d28]
netlify_dns_record.nixos["umbriel.nixos.org-AAAA"]: Refreshing state... [id=6552aeb037f2db42d01f287a]
netlify_dns_record.nixos["pluto.nixos.org-AAAA"]: Refreshing state... [id=65d6859727a8aa20f3901c3c]
netlify_dns_record.nixos["monitoring.nixos.org-CNAME"]: Refreshing state... [id=65da80798238d75d288f1ae7]
netlify_dns_record.nixos["cache.nixos.org-CNAME"]: Refreshing state... [id=615af97f5d87520b69d067c2]
netlify_dns_record.nixos["status.nixos.org-CNAME"]: Refreshing state... [id=615b01e6858de3185d3f51b1]
netlify_dns_record.nixos["reproducible.nixos.org-CNAME"]: Refreshing state... [id=6422b3c458d3a93fad78f5b0]
netlify_dns_record.nixos["nixpkgs-merge-bot.nixos.org-A"]: Refreshing state... [id=652e890c1f97b006b8a9fbfe]
netlify_dns_record.nixos["20th.nixos.org-CNAME"]: Refreshing state... [id=64137cd29c4f020bf9a4ffcc]
netlify_dns_record.nixos["growing-jennet.mac.nixos.org-A"]: Refreshing state... [id=6331b522325bc5007926d18c]
netlify_dns_record.nixos["_acme-challenge.releases.nixos.org-CNAME"]: Refreshing state... [id=615af8f2858de309a73f594f]
netlify_dns_record.nixos["wiki.nixos.org-A"]: Refreshing state... [id=65ca04d6ae0ededa3a0a9718]
netlify_dns_record.nixos["pluto.nixos.org-A"]: Refreshing state... [id=65d68597ec15051f733c1813]
netlify_dns_record.nixos["caliban.nixos.org-TXT"]: Refreshing state... [id=665ecb6c77ca60df9ff87b60]
netlify_dns_record.nixos["_293364b7f7ebb076ac287cd132f8b316.cache.ngi0.nixos.org-CNAME"]: Refreshing state... [id=615afd1f6cb28413a0637d11]
netlify_dns_record.nixos["nixos.org-TXT"]: Refreshing state... [id=652d6570830b9933187f8dbc]
netlify_dns_record.nixos["rhea.nixos.org-AAAA"]: Refreshing state... [id=6245af4151b7df6194da1110]
netlify_dns_record.nixos["_dmarc.wiki.nixos.org-TXT"]: Refreshing state... [id=65e8b03f8776702e5c2336c5]
netlify_dns_record.nixos["weekly.nixos.org-CNAME"]: Refreshing state... [id=615af96558bc280c8ccbebe4]
netlify_dns_record.nixos["hydra.nixos.org-CNAME"]: Refreshing state... [id=6245b2c57e84b864041120da]
netlify_dns_record.nixos["netboot.nixos.org-CNAME"]: Refreshing state... [id=65d7142727a8aa844b901d88]
netlify_dns_record.nixos["discourse.nixos.org-TXT"]: Refreshing state... [id=6181546fa0a3fffbc3d6df8f]
netlify_dns_record.nixos["mail._domainkey.caliban.nixos.org-TXT"]: Refreshing state... [id=665f1604b766091997dee849]
aws_s3_bucket.channels: Refreshing state... [id=nix-channels]
aws_s3_bucket.cache: Refreshing state... [id=nix-cache]
aws_s3_bucket.cache_log: Refreshing state... [id=nix-cache-log]
aws_s3_bucket.cache_inventory: Refreshing state... [id=nix-cache-inventory]
aws_s3_bucket_object.nixpkgs-tarballs-index: Refreshing state... [id=index.html]
aws_s3_bucket_policy.nixpkgs-tarballs: Refreshing state... [id=nixpkgs-tarballs]
aws_s3_bucket_inventory.releases_inventory: Refreshing state... [id=nix-releases:nix-releases-inventory]
aws_s3_bucket_policy.releases: Refreshing state... [id=nix-releases]
aws_s3_bucket_object.releases-index-html: Refreshing state... [id=index.html]
aws_s3_bucket_policy.channels: Refreshing state... [id=nix-channels]
aws_s3_bucket_object.channels-index-html: Refreshing state... [id=index.html]
aws_s3_bucket_lifecycle_configuration.cache_log: Refreshing state... [id=nix-cache-log]
aws_s3_bucket_request_payment_configuration.cache: Refreshing state... [id=nix-cache]
aws_s3_bucket_logging.cache_log: Refreshing state... [id=nix-cache]
aws_s3_bucket_inventory.cache_inventory: Refreshing state... [id=nix-cache:nix-cache-inventory]
data.aws_iam_policy_document.cache_log: Reading...
aws_s3_bucket_object.cache-nix-cache-info: Refreshing state... [id=nix-cache-info]
aws_s3_bucket_policy.cache: Refreshing state... [id=nix-cache]
aws_s3_bucket_object.cache-index-html: Refreshing state... [id=index.html]
data.aws_iam_policy_document.cache_log: Read complete after 0s [id=3967206474]
aws_s3_bucket_policy.cache_log: Refreshing state... [id=nix-cache-log]

Makes it easier to tell flake-modules from other files.
@Mic92 Mic92 requested a review from a team as a code owner August 18, 2024 05:43
also switch to opentofu to avoid unfree package evaluation
Since we manage terraform plugins with nix, we don't need these lock
files to pin modules.
@Mic92 Mic92 force-pushed the terraform-iam-cleanups branch 2 times, most recently from c02fe45 to 89dbf77 Compare August 18, 2024 06:43
p.netlify
p.secret
] ++ [
# FIXME: for our `terraform` target our state file still uses the old registry prefix
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to patch the state after this pull request is merged to not break the existing setup.

our terraform targets are similar enough that we can just share devShell
between them
we use nix for pinning instead.
@Mic92 Mic92 changed the title Terraform iam cleanups Terraform cleanups Aug 18, 2024
Copy link
Member

@zimbatm zimbatm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sound good. Terragrunt as a more graceful auto-init feature that could be used instead.


cd "$(dirname "$0")"
rm -f .terraform.lock.hcl
tofu init
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this slow down each terraform invocation?

@Mic92
Copy link
Member Author

Mic92 commented Aug 18, 2024

Agreed. It would also make it easier to split up targets.

@Mic92 Mic92 merged commit 33acac7 into master Aug 18, 2024
1 check passed
@Mic92 Mic92 deleted the terraform-iam-cleanups branch August 18, 2024 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants