Hello,
I reached the question 10/14 in the lab Lab: Functions and Conditional Expressions of the course " Terraform Basics Training Course". I had an error related to state lock that is not related to the context.
Can you please help me about it?
Using the solution (which you appear to be doing as well), I did not get this error. You do need to run terraform init
first to make sure that all of the needed initialization is done. When I did terraform apply
, I got something like this:
❯ terraform apply
aws_iam_user.cloud[1]: Refreshing state... [id=ken]
aws_iam_user.cloud[3]: Refreshing state... [id=mutsumi]
aws_iam_user.cloud[4]: Refreshing state... [id=peter]
aws_iam_user.cloud[2]: Refreshing state... [id=faraz]
aws_iam_user.cloud[0]: Refreshing state... [id=andrew]
aws_iam_user.cloud[5]: Refreshing state... [id=steve]
aws_iam_user.cloud[6]: Refreshing state... [id=braja]
Terraform used the selected providers to generate the
following execution plan. Resource actions are indicated with
the following symbols:
+ create
Terraform will perform the following actions:
# aws_s3_bucket.sonic_media will be created
+ resource "aws_s3_bucket" "sonic_media" {
+ acceleration_status = (known after apply)
+ acl = (known after apply)
+ arn = (known after apply)
+ bucket = "sonic-media"
+ bucket_domain_name = (known after apply)
+ bucket_regional_domain_name = (known after apply)
+ force_destroy = false
+ hosted_zone_id = (known after apply)
+ id = (known after apply)
+ object_lock_enabled = (known after apply)
+ policy = (known after apply)
+ region = (known after apply)
+ request_payer = (known after apply)
+ tags_all = (known after apply)
+ website_domain = (known after apply)
+ website_endpoint = (known after apply)
}
# aws_s3_object.upload_sonic_media["/media/eggman.jpg"] will be created
+ resource "aws_s3_object" "upload_sonic_media" {
+ acl = "private"
+ bucket = (known after apply)
+ bucket_key_enabled = (known after apply)
+ content_type = (known after apply)
+ etag = (known after apply)
+ force_destroy = false
+ id = (known after apply)
+ key = "eggman.jpg"
+ kms_key_id = (known after apply)
+ server_side_encryption = (known after apply)
+ source = "/media/eggman.jpg"
+ storage_class = (known after apply)
+ tags_all = (known after apply)
+ version_id = (known after apply)
}
# aws_s3_object.upload_sonic_media["/media/knuckles.jpg"] will be created
+ resource "aws_s3_object" "upload_sonic_media" {
+ acl = "private"
+ bucket = (known after apply)
+ bucket_key_enabled = (known after apply)
+ content_type = (known after apply)
+ etag = (known after apply)
+ force_destroy = false
+ id = (known after apply)
+ key = "knuckles.jpg"
+ kms_key_id = (known after apply)
+ server_side_encryption = (known after apply)
+ source = "/media/knuckles.jpg"
+ storage_class = (known after apply)
+ tags_all = (known after apply)
+ version_id = (known after apply)
}
# aws_s3_object.upload_sonic_media["/media/shadow.jpg"] will be created
+ resource "aws_s3_object" "upload_sonic_media" {
+ acl = "private"
+ bucket = (known after apply)
+ bucket_key_enabled = (known after apply)
+ content_type = (known after apply)
+ etag = (known after apply)
+ force_destroy = false
+ id = (known after apply)
+ key = "shadow.jpg"
+ kms_key_id = (known after apply)
+ server_side_encryption = (known after apply)
+ source = "/media/shadow.jpg"
+ storage_class = (known after apply)
+ tags_all = (known after apply)
+ version_id = (known after apply)
}
# aws_s3_object.upload_sonic_media["/media/tails.jpg"] will be created
+ resource "aws_s3_object" "upload_sonic_media" {
+ acl = "private"
+ bucket = (known after apply)
+ bucket_key_enabled = (known after apply)
+ content_type = (known after apply)
+ etag = (known after apply)
+ force_destroy = false
+ id = (known after apply)
+ key = "tails.jpg"
+ kms_key_id = (known after apply)
+ server_side_encryption = (known after apply)
+ source = "/media/tails.jpg"
+ storage_class = (known after apply)
+ tags_all = (known after apply)
+ version_id = (known after apply)
}
# aws_s3_object.upload_sonic_media["/media/ultrasonic.jpg"] will be created
+ resource "aws_s3_object" "upload_sonic_media" {
+ acl = "private"
+ bucket = (known after apply)
+ bucket_key_enabled = (known after apply)
+ content_type = (known after apply)
+ etag = (known after apply)
+ force_destroy = false
+ id = (known after apply)
+ key = "ultrasonic.jpg"
+ kms_key_id = (known after apply)
+ server_side_encryption = (known after apply)
+ source = "/media/ultrasonic.jpg"
+ storage_class = (known after apply)
+ tags_all = (known after apply)
+ version_id = (known after apply)
}
Plan: 6 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
aws_s3_bucket.sonic_media: Creating...
aws_s3_bucket.sonic_media: Creation complete after 1s [id=sonic-media]
aws_s3_object.upload_sonic_media["/media/knuckles.jpg"]: Creating...
aws_s3_object.upload_sonic_media["/media/shadow.jpg"]: Creating...
aws_s3_object.upload_sonic_media["/media/eggman.jpg"]: Creating...
aws_s3_object.upload_sonic_media["/media/ultrasonic.jpg"]: Creating...
aws_s3_object.upload_sonic_media["/media/tails.jpg"]: Creating...
aws_s3_object.upload_sonic_media["/media/knuckles.jpg"]: Creation complete after 0s [id=knuckles.jpg]
aws_s3_object.upload_sonic_media["/media/eggman.jpg"]: Creation complete after 0s [id=eggman.jpg]
aws_s3_object.upload_sonic_media["/media/shadow.jpg"]: Creation complete after 0s [id=shadow.jpg]
aws_s3_object.upload_sonic_media["/media/ultrasonic.jpg"]: Creation complete after 0s [id=ultrasonic.jpg]
aws_s3_object.upload_sonic_media["/media/tails.jpg"]: Creation complete after 0s [id=tails.jpg]
Apply complete! Resources: 6 added, 0 changed, 0 destroyed.
root in ~/terraform-projects/project-sonic via 💠 default on ☁️ (us-east-1) took 8s
❯