douglasnaphas / hatgame

A web application for virtually playing the Hat Game. Players put things into a hat, then take them out and act on them.
Apache License 2.0
0 stars 0 forks source link

Upgrade to Terraform v0.13 in Terraform Cloud #10

Closed douglasnaphas closed 1 year ago

douglasnaphas commented 4 years ago
| ~/repos/hatgame/infra/prod @ Dougs-MBP (dougnaphas) [18:59:26] master Δ
| 6022 => tf13 state list
data.aws_route53_zone.this[0]
aws_s3_bucket.bucket
module.acm.aws_acm_certificate.this[0]
module.acm.aws_acm_certificate_validation.this[0]
module.acm.aws_route53_record.validation[0]
module.acm.aws_route53_record.validation[1]
module.s3-cf-site.data.aws_acm_certificate.tls_cert
module.s3-cf-site.data.aws_route53_zone.zone
module.s3-cf-site.aws_cloudfront_distribution.cf_distro
module.s3-cf-site.aws_cloudfront_origin_access_identity.cf_oai
module.s3-cf-site.aws_route53_record.cf_alias
module.s3-cf-site.aws_s3_bucket.bucket
module.s3-cf-site.aws_s3_bucket_policy.bucket_policy
______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
| ~/repos/hatgame/infra/prod @ Dougs-MBP (dougnaphas) [19:55:55] tf13-upgrade
| 6023 => tf13 state show module.s3-cf-site.aws_cloudfront_distribution.cf_distro
unsupported attribute "active_trusted_signers"
# module.s3-cf-site.aws_cloudfront_distribution.cf_distro:
resource "aws_cloudfront_distribution" "cf_distro" {
______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
| ~/repos/hatgame/infra/prod @ Dougs-MBP (dougnaphas) [19:56:09] tf13-upgrade
| 6024 => tf12 state show module.s3-cf-site.aws_cloudfront_distribution.cf_distro

Warning: Interpolation-only expressions are deprecated

  on .terraform/modules/s3-cf-site/terraform-aws-s3-cf-site-0.1.0/cloudfront.tf line 38, in resource "aws_cloudfront_distribution" "cf_distro":
  38:       origin_access_identity = "${aws_cloudfront_origin_access_identity.cf_oai.cloudfront_access_identity_path}"

Terraform 0.11 and earlier required all non-constant expressions to be
provided via interpolation syntax, but this pattern is now deprecated. To
silence this warning, remove the "${ sequence from the start and the }"
sequence from the end of this expression, leaving just the inner expression.

Template interpolation syntax is still used to construct strings from
expressions when the template includes multiple interpolation sequences or a
mixture of literal strings and interpolations. This deprecation applies only
to templates that consist entirely of a single interpolation sequence.

(and 7 more similar warnings elsewhere)

Warning: Provider source not supported in Terraform v0.12

  on /Users/dougnaphas/repos/hatgame/infra/prod/versions.tf line 3, in terraform:
   3:     aws = {
   4:       source = "hashicorp/aws"
   5:     }

A source was declared for provider aws. Terraform v0.12 does not support the
provider source attribute. It will be ignored.

Error: Unsupported Terraform Core version

  on /Users/dougnaphas/repos/hatgame/infra/prod/versions.tf line 7, in terraform:
   7:   required_version = ">= 0.13"

This configuration does not support Terraform version 0.12.29. To proceed,
either choose another supported Terraform version or update this version
constraint. Version constraints are normally set for good reason, so updating
the constraint may lead to other errors or unexpected behavior.

______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
| ~/repos/hatgame/infra/prod @ Dougs-MBP (dougnaphas) [20:03:18] tf13-upgrade
| 6025 => # time to try removing and importing the resource, based on https://stackoverflow.com/questions/63411522/upgrading-terraform-provider-results-in-invalid-resource-instance-data-in-state
douglasnaphas commented 4 years ago

Removing the CF distro from the remote state, and then re-importing it, worked, all from the command line. The update state shows up in Terraform Cloud.

douglasnaphas commented 4 years ago

Done, tf13 is working with this repo now.

douglasnaphas commented 4 years ago

Actually, tf13 is not working, as explained here.

douglasnaphas commented 4 years ago

I need to fall back to tf12. Steps:

douglasnaphas commented 4 years ago

Maybe I could delete the provider source

The warning in the output below makes me wonder whether I could address the errors I'm seeing on tf13 by deleting my provider source.

$ AWS_PROFILE=douglas tf12 init
Initializing modules...
Downloading terraform-aws-modules/acm/aws 2.10.0 for acm...
- acm in .terraform/modules/acm/terraform-aws-acm-2.10.0
Downloading douglasnaphas/s3-cf-site/aws 0.3.0 for s3-cf-site...
- s3-cf-site in .terraform/modules/s3-cf-site/terraform-aws-s3-cf-site-0.3.0

Initializing the backend...

Successfully configured the backend "local"! Terraform will automatically
use this backend unless the backend configuration changes.

Initializing provider plugins...
- Checking for available provider plugins...
- Downloading plugin for provider "aws" (hashicorp/aws) 3.2.0...

Warning: Provider source not supported in Terraform v0.12

  on versions.tf line 3, in terraform:
   3:     aws = {
   4:       source = "hashicorp/aws"
   5:     }

A source was declared for provider aws. Terraform v0.12 does not support the
provider source attribute. It will be ignored.

Terraform has been successfully initialized!

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

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
douglasnaphas commented 4 years ago

I told HashiCorp support:

Hi, Georgi:

I had reviewed the upgrade guide previously, but let me let me try adding required_provider blocks with the source specified as in this section (https://www.terraform.io/upgrade-guides/0-13.html#explicit-provider-source-locations) to the modules that I am importing. I will probably not be able to make and test this change until some time on Wednesday, August 19.

Thank you, Doug

douglasnaphas commented 4 years ago

I could also try this:

https://github.com/hashicorp/terraform/issues/23290#issuecomment-675623799 https://support.hashicorp.com/hc/en-us/articles/360041299873

douglasnaphas commented 4 years ago

I'm un-stuck on tf12 thanks to an ACM cert quota increase. I need to sort out my S3/CF module so that it actually creates and uses a cert if one is already there instead of using the existing one and then creating another one and not using it, but that doesn't block me from getting a front-end pipeline set up on Hat Game, so I will probably defer it.

douglasnaphas commented 1 year ago

Not using Terraform, closing.