TechToSpeech / terraform-aws-serverless-static-wordpress

Terraform module for deploying Serverless Static Wordpress on AWS
GNU General Public License v3.0
196 stars 69 forks source link

fix: pass site_prefix to CloudFront module #66

Open blimmer opened 2 years ago

blimmer commented 2 years ago

This PR updates main.tf to pass the site_prefix variable to the CloudFront module. The module references the site prefix when creating the Wordpress bucket: https://github.com/TechToSpeech/terraform-aws-serverless-static-wordpress/blob/abc903d9d3aabbb2fbb51e47679c0b2c61b3f6e7/modules/cloudfront/distribution.tf#L4-L5

However, site_prefix was not passed from the main module instantiation to the submodule. For me, this caused an error because I already had an S3 bucket with the www.<site_domain>.com created. www is the variable default defined here: https://github.com/TechToSpeech/terraform-aws-serverless-static-wordpress/blob/abc903d9d3aabbb2fbb51e47679c0b2c61b3f6e7/modules/cloudfront/variables.tf#L6-L10

Error creating S3 bucket: BucketAlreadyOwnedByYou: Your previous request to create the named bucket succeeded and you already own it.

By passing through the site prefix, with this PR, I was able to get past the error and create the bucket <custom_site_prefix>.<site_domain>.com.