Skip to content

Commit

Permalink
Cloudfront s3 (#997)
Browse files Browse the repository at this point in the history
* git status

* Setting assets to pull from main branch

* Updating scratch hcl

* Formatting

* Removing branch on git pull of admin

* Added comment on reasoning around this change

* Finishing my thought

* Update aws/common/uploadS3Assets.tf

Co-authored-by: Jimmy Royer <[email protected]>

---------

Co-authored-by: Jimmy Royer <[email protected]>
  • Loading branch information
ben851 and jimleroyer authored Nov 1, 2023
1 parent 0f67d70 commit fbb46c5
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 0 deletions.
11 changes: 11 additions & 0 deletions aws/common/uploadS3Assets.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This is hack'ish as we're cloning an external repo into a temp directory so that we can populate CloudFront.
# We will have to review a better way of doing this in the future, but our long term goal of having one source of
# truth for the assets is accomplished.

resource "aws_s3_object" "assets" {

bucket = aws_s3_bucket.asset_bucket.id
for_each = fileset("/var/tmp/notification-admin/app/assets/cloudfront", "**")
key = each.value
source = "/var/tmp/notification-admin/app/assets/cloudfront/${each.value}"
}
14 changes: 14 additions & 0 deletions env/dev/common/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
terraform {
source = "../../../aws//common"

before_hook "get-admin" {
commands = ["apply", "plan"]
execute = ["git", "clone", "https://github.com/cds-snc/notification-admin.git", "/var/tmp/notification-admin"]
run_on_error = true

}

after_hook "cleanup-admin" {
commands = ["apply", "plan"]
execute = ["rm", "-rfd", "/var/tmp/notification-admin"]
run_on_error = true
}

}

include {
Expand Down
25 changes: 25 additions & 0 deletions env/dev/quicksight/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions env/production/common/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@
#
terraform {
source = "git::https://github.com/cds-snc/notification-terraform//aws/common?ref=v${get_env("INFRASTRUCTURE_VERSION")}"

before_hook "get-admin" {
commands = ["apply", "plan"]
execute = ["git", "clone", "https://github.com/cds-snc/notification-admin.git", "/var/tmp/notification-admin"]
run_on_error = true

}

after_hook "cleanup-admin" {
commands = ["apply", "plan"]
execute = ["rm", "-rfd", "/var/tmp/notification-admin"]
run_on_error = true
}
}

include {
Expand Down
14 changes: 14 additions & 0 deletions env/scratch/common/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
terraform {
source = "../../../aws//common"

before_hook "get-admin" {
commands = ["apply", "plan"]
execute = ["git", "clone", "https://github.com/cds-snc/notification-admin.git", "/var/tmp/notification-admin"]
run_on_error = true

}

after_hook "cleanup-admin" {
commands = ["apply", "plan"]
execute = ["rm", "-rfd", "/var/tmp/notification-admin"]
run_on_error = true
}

}

include {
Expand Down
13 changes: 13 additions & 0 deletions env/staging/common/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
terraform {
source = "../../../aws//common"

before_hook "get-admin" {
commands = ["apply", "plan"]
execute = ["git", "clone", "https://github.com/cds-snc/notification-admin.git", "/var/tmp/notification-admin"]
run_on_error = true

}

after_hook "cleanup-admin" {
commands = ["apply", "plan"]
execute = ["rm", "-rfd", "/var/tmp/notification-admin"]
run_on_error = true
}
}

include {
Expand Down

0 comments on commit fbb46c5

Please sign in to comment.