hashicorp / learn-terraform-console

https://learn.hashicorp.com/tutorials/terraform/console?in=terraform/cli
Mozilla Public License 2.0
2 stars 3 forks source link

found a mistake? #2

Open ihavenoideaforusername opened 2 years ago

ihavenoideaforusername commented 2 years ago

i was doing this tutorial Develop Configuration with the Console | Terraform - HashiCorp Learn

and i came across a problem with first terraform init i got following error:

Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/aws:
│ locked provider registry.terraform.io/hashicorp/aws 3.58.0 does not match
│ configured version constraint ~> 4.0.0; must use terraform init -upgrade to
│ allow selection of new versions

so i changed the constraint in main.tf to version = "~> 3.58.0" the error after applying:

Error: Invalid data source
│
│   on main.tf line 24, in data "aws_s3_objects" "data_bucket":
│   24: data "aws_s3_objects" "data_bucket" {
│
│ The provider hashicorp/aws does not support data source "aws_s3_objects".

so i delete the folder, git cloned once again and this time i used previously adviced terraform init -upgrade,

after using terraform apply i got error:

Error: Value for unconfigurable attribute
│
│   with aws_s3_bucket.data,
│   on main.tf line 21, in resource "aws_s3_bucket" "data":
│   21:   acl = "private"
│
│ Can't configure a value for "acl": its value will be decided automatically
│ based on the result of applying this configuration.
╵

what should i do?

AudiArduino commented 1 year ago

Hi about the "terraform apply"... I had the same issue there is an issue in the main.tf error creating s3 bucket acl the bucket does not allow acls.... I'm not sure but after modifying like the following it worked: (referring to the registry https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_acl)

provider "aws" { region = var.aws_region

default_tags { tags = { hashicorp-learn = "console" } } }

resource "aws_s3_bucket" "data" { bucket_prefix = var.bucket_prefix

force_destroy = true }

resource "aws_s3_bucket_ownership_controls" "data" { bucket = aws_s3_bucket.data.id rule { object_ownership = "BucketOwnerPreferred" } }

resource "aws_s3_bucket_acl" "data" { depends_on = [aws_s3_bucket_ownership_controls.data] bucket = aws_s3_bucket.data.id acl = "private" }

data "aws_s3_objects" "data_bucket" { bucket = aws_s3_bucket.data.bucket }