Skip to content

Commit 1ae671d

Browse files
AaaCabbageqixin
andauthored
Add 'aws_site_error_document' config support (#18)
* add var 'aws_site_error_document' in variables.tf * add error_document to bucket website config in main.tf * add aws_site_error_document in generate_deploy.sh * Add 'aws_site_error_document' in action.yaml * Update action.yaml * Revert "Update action.yaml" This reverts commit afe02eb. * Set the error document to an empty string by default in variables.tf * Update variables.tf --------- Co-authored-by: qixin <[email protected]>
1 parent b581387 commit 1ae671d

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

action.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ inputs:
5555
aws_site_root_object:
5656
description: 'Root object to be served as entry-point. Defaults to `index.html`'
5757
required: false
58+
aws_site_error_document:
59+
description: 'Error document set to S3 website config. Defaults to `error.html`'
60+
required: false
5861
aws_site_bucket_name:
5962
description: ' AWS S3 bucket name to use for the public files. Defaults to `${org}-${repo}-{branch}-sp`'
6063
required: false
@@ -121,6 +124,7 @@ runs:
121124
# Site
122125
AWS_SITE_SOURCE_FOLDER: ${{ inputs.aws_site_source_folder }}
123126
AWS_SITE_ROOT_OBJECT: ${{ inputs.aws_site_root_object }}
127+
AWS_SITE_ERROR_DOCUMENT: ${{ inputs.aws_site_error_document }}
124128
AWS_SITE_BUCKET_NAME: ${{ inputs.aws_site_bucket_name }}
125129
AWS_SITE_CDN_ENABLED: ${{ inputs.aws_site_cdn_enabled }}
126130
AWS_SITE_CDN_CUSTOM_ERROR_CODES: ${{ inputs.aws_site_cdn_custom_error_codes }}
@@ -220,4 +224,4 @@ runs:
220224
run: |
221225
echo "## Workflow failed to run :fire:" >> $GITHUB_STEP_SUMMARY
222226
echo "Please check the logs for possible errors." >> $GITHUB_STEP_SUMMARY
223-
echo "If you consider this is a bug in the Github Action, please submit an issue to our repo." >> $GITHUB_STEP_SUMMARY
227+
echo "If you consider this is a bug in the Github Action, please submit an issue to our repo." >> $GITHUB_STEP_SUMMARY

scripts/generate_deploy.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ aws_site_bucket_name=$(generate_var aws_site_bucket_name $AWS_SITE_BUCKET_NAME)
9090
aws_site_cdn_enabled=$(generate_var aws_site_cdn_enabled $AWS_SITE_CDN_ENABLED)
9191
aws_site_cdn_custom_error_codes=$(generate_var aws_site_cdn_custom_error_codes $AWS_SITE_CDN_CUSTOM_ERROR_CODES)
9292
aws_site_root_object=$(generate_var aws_site_root_object $AWS_SITE_ROOT_OBJECT)
93+
aws_site_error_document=$(generate_var aws_site_error_document $AWS_SITE_ERROR_DOCUMENT)
9394
aws_r53_domain_name=$(generate_var aws_r53_domain_name $AWS_R53_DOMAIN_NAME)
9495
aws_r53_root_domain_deploy=$(generate_var aws_r53_root_domain_deploy $AWS_R53_ROOT_DOMAIN_DEPLOY)
9596
#aws_r53_enable_cert=$(generate_var aws_r53_enable_cert $AWS_R53_ENABLE_CERT)
@@ -110,6 +111,7 @@ $aws_site_bucket_name
110111
$aws_site_cdn_enabled
111112
$aws_site_cdn_custom_error_codes
112113
$aws_site_root_object
114+
$aws_site_error_document
113115
$aws_r53_domain_name
114116
$aws_r53_sub_domain_name
115117
$aws_r53_root_domain_deploy

terraform_code/main.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ resource "aws_s3_bucket_website_configuration" "aws_site_website_bucket" {
99
index_document {
1010
suffix = var.aws_site_root_object
1111
}
12+
13+
error_document {
14+
key = var.aws_site_error_document
15+
}
1216
}
1317

1418
## Only create this two IF -> R53 FQDN provided and CDN is off - for www.* support
@@ -469,4 +473,4 @@ output "cloudfront_url" {
469473

470474
output "public_url" {
471475
value = local.public_url
472-
}
476+
}

terraform_code/variables.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ variable "aws_site_root_object" {
3131
default = "index.html"
3232
}
3333

34+
variable "aws_site_error_document" {
35+
description = "error document. Defaults to empty"
36+
type = string
37+
default = ""
38+
}
39+
3440
variable "aws_site_bucket_name" {
3541
description = "Bucket name where all the files will be stored."
3642
type = string
@@ -115,4 +121,4 @@ locals {
115121
GitHubAction = "bitovi/github-actions-deploy-static-site-to-aws"
116122
created_with = "terraform"
117123
}
118-
}
124+
}

0 commit comments

Comments
 (0)