Skip to content

Commit 2d1ccb9

Browse files
Copilotcvangerpen
andauthored
Fix: CodeBuild syncing to config bucket instead of content bucket (#7)
* Initial plan * Restore filmdrop_ui_bucket_name variable and fix CONTENT_BUCKET reference Co-authored-by: cvangerpen <179522148+cvangerpen@users.noreply.github.com> * Update CHANGELOG with fix details Co-authored-by: cvangerpen <179522148+cvangerpen@users.noreply.github.com> * Simplify bucket_prefix by removing random_id resource Co-authored-by: cvangerpen <179522148+cvangerpen@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: cvangerpen <179522148+cvangerpen@users.noreply.github.com>
1 parent ec95b67 commit 2d1ccb9

5 files changed

Lines changed: 44 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2424

2525
### Added
2626

27+
- Restored `filmdrop_ui_bucket_name` input variable to specify the S3 bucket for deploying the built UI application
28+
2729
### Changed
2830

2931
### Fixed
3032

33+
- Fixed `CONTENT_BUCKET` environment variable to use `filmdrop_ui_bucket_name` instead of the config bucket, preventing the built UI from being synced to the same bucket as the CodeBuild configuration
34+
3135
### Removed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ Before using this module, ensure you have:
5959
- Security groups allowing outbound traffic
6060
- VPC ID and subnet IDs
6161

62-
3. **S3 Bucket**:
63-
- Creates an S3 bucket to hold the build configuration
64-
- *Requires* an already existing bucket for the application to be deployed to
62+
3. **S3 Buckets**:
63+
- The module automatically creates an S3 bucket to hold the CodeBuild configuration (buildspec.yml)
64+
- *Requires* an already existing S3 bucket for the built application to be deployed to (specified via `filmdrop_ui_bucket_name` variable)
6565

6666
4. **Configuration Files**:
6767
- **Filmdrop UI Config JSON** (`./utils/config.dev.json`): Configuration file for the Filmdrop-UI application (see [Filmdrop UI documentation](https://github.com/Element84/filmdrop-ui) for structure)
@@ -170,6 +170,7 @@ No modules.
170170

171171
| Name | Description | Type | Default | Required |
172172
|------|-------------|------|---------|:--------:|
173+
| <a name="input_filmdrop_ui_bucket_name"></a> [filmdrop\_ui\_bucket\_name](#input\_filmdrop\_ui\_bucket\_name) | Name of the S3 bucket where the built FilmDrop UI application will be deployed | `string` | n/a | yes |
173174
| <a name="input_filmdrop_ui_config"></a> [filmdrop\_ui\_config](#input\_filmdrop\_ui\_config) | The base64 encoded file contents of the Filmdrop UI Deployment Config File | `string` | n/a | yes |
174175
| <a name="input_filmdrop_ui_logo"></a> [filmdrop\_ui\_logo](#input\_filmdrop\_ui\_logo) | The base64 encoded file contents of the supplied custom logo | `string` | n/a | yes |
175176
| <a name="input_filmdrop_ui_logo_file"></a> [filmdrop\_ui\_logo\_file](#input\_filmdrop\_ui\_logo\_file) | File of the supplied custom logo | `string` | n/a | yes |

filmdrop_ui.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ resource "aws_codebuild_project" "filmdrop_ui_codebuild" {
4848

4949
environment_variable {
5050
name = "CONTENT_BUCKET"
51-
value = aws_s3_bucket.filmdrop_ui_source_config.bucket
51+
value = var.filmdrop_ui_bucket_name
5252
}
5353
}
5454

inputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,8 @@ variable "filmdrop_ui_logo" {
3838
description = "The base64 encoded file contents of the supplied custom logo"
3939
type = string
4040
}
41+
42+
variable "filmdrop_ui_bucket_name" {
43+
description = "Name of the S3 bucket where the built FilmDrop UI application will be deployed"
44+
type = string
45+
}

utils/cicd/main.tf

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,42 @@ module "vpc-data" {
88
source = "./vpc-data"
99
}
1010

11+
# Create the content bucket where the built UI will be deployed
12+
resource "aws_s3_bucket" "filmdrop_ui_content" {
13+
bucket_prefix = "filmdrop-ui-content-"
14+
force_destroy = true
15+
}
16+
17+
resource "aws_s3_bucket_ownership_controls" "filmdrop_ui_content_ownership_controls" {
18+
bucket = aws_s3_bucket.filmdrop_ui_content.id
19+
rule {
20+
object_ownership = "BucketOwnerPreferred"
21+
}
22+
}
23+
24+
resource "aws_s3_bucket_public_access_block" "filmdrop_ui_content_public_access_block" {
25+
bucket = aws_s3_bucket.filmdrop_ui_content.id
26+
27+
block_public_acls = true
28+
block_public_policy = true
29+
ignore_public_acls = true
30+
restrict_public_buckets = true
31+
}
32+
33+
resource "aws_s3_bucket_versioning" "filmdrop_ui_content_versioning" {
34+
bucket = aws_s3_bucket.filmdrop_ui_content.id
35+
versioning_configuration {
36+
status = "Enabled"
37+
}
38+
}
39+
1140
module "main" {
1241
source = "../.."
1342
filmdrop_ui_logo_file = "./logo.png"
1443
filmdrop_ui_config = filebase64("./config.dev.json")
1544
filmdrop_ui_logo = filebase64("./logo.png")
1645
filmdrop_ui_release_tag = "v6.1.1-0"
46+
filmdrop_ui_bucket_name = aws_s3_bucket.filmdrop_ui_content.id
1747
vpc_id = module.vpc-data.vpc_id
1848
vpc_private_subnet_ids = module.vpc-data.private_subnet_ids
1949
vpc_security_group_ids = [module.vpc-data.security_group_id]

0 commit comments

Comments
 (0)