hashicorp/terraform-provider-aws

[Bug]: Resource aws_s3_bucket_versioning can't be created for s3 outpost bucket

Open

#33,119 opened on Aug 21, 2023

 (5 comments) (1 reaction) (0 assignees)Go (10,310 forks)github user discovery
enhancementgood first issuenew-resourceservice/s3control

Repository metrics

Stars
 (11,045 stars)
PR merge metrics
 (PR metrics pending)

Description

Terraform Core Version

5.13.1

AWS Provider Version

1.5.5

Affected Resource(s)

aws_s3_bucket_versioning

Expected Behavior

For the bucket on the s3 outpost, a resource for versioning should be created and versioning would be enabled. I expect that after providing the bucket's name or access point of the s3 bucket on the outpost, this resource could be created.

Actual Behavior

When as a parameter for the resource aws_s3_bucket_versioning I set arn of the access point to the bucket I get an error: Error: expected length of the bucket to be in the range (1 - 63), got arn:aws:s3-outposts:us-west-2:xxxxxxxxxxxx:outpost/op-xxxxxxxxxxxxxxxx/bucket/test0001

Whereas when I tried to set the parameter as an arn to the bucket I got Error: expected length of bucket to be in the range (1 - 63), got arn:aws:s3-outposts:us-west-2:xxxxxxxxxxxx:outpost/op-xxxxxxxxxxxxxxxx/accesspoint/ap-test0001

When I tried just to use the bucket name I got an error:

Error: creating S3 bucket versioning for test0001: BucketRegionError: incorrect region, the bucket is not in 'us-west-2' region at endpoint '', bucket is in 'us-east-1' region

the third error I was expected because a bucket is on s3 outpost, but for the previous two the resource aws_s3_bucket_versioning should handle the situation when you use s3 outpost.

** For outpost id and account id I redacted them

Relevant Error/Panic Output Snippet

`Error: expected length of the bucket to be in the range (1 - 63), got arn:aws:s3-outposts:us-west-2:xxxxxxxxxxxx:outpost/op-xxxxxxxxxxxxxxxx/bucket/test0001`

Terraform Configuration Files

variable "vpc_id" {
  type        = string
  description = "vpc id"
}

variable "outpost_id" {
  type        = string
  description = "outpost id"
}


resource "aws_s3control_bucket" "bucket_name" {
  bucket     = "test0001"
  outpost_id = var.outpost_id

}


resource "aws_s3_access_point" "op_access_point" {
  bucket = aws_s3control_bucket.bucket_name.id
  name   = "ap-test0001"


  vpc_configuration {
    vpc_id = var.vpc_id
  }
}



resource "aws_s3_bucket_versioning" "backend_outpost_local" {
  bucket = aws_s3control_bucket.bucket_name.arn
  versioning_configuration {
    status = "Enabled"
  }

}

Steps to Reproduce

  1. Assuming you have access to s3 outpost, you should create your own vpc and subnet
  2. In s3 outpost console create s3 endpoint associated with the created vpc's subnet(for simplification security group for the s3 endpoint should be set to have open port 443 to inbound traffic on your own public address and for outbound you can set All traffic)
  3. Apply the above terraform code, vpc_id and ednpoint_id you should take from steps 1 and 2.
  4. Resource aws_s3control_bucket should be created, but during creation aws_s3_bucket_versioning, you should get an error I described.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

Contributor guide