Skip to content

Commit d880b7e

Browse files
authored
Adding managed policies input (#23)
- Add logo to summary - Add managed policies input
1 parent e153d2a commit d880b7e

File tree

5 files changed

+38
-4
lines changed

5 files changed

+38
-4
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262

6363
steps:
6464
- name: Create deploy-bucket
65-
uses: bitovi/[email protected].3
65+
uses: bitovi/[email protected].7
6666
with:
6767
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
6868
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
@@ -91,7 +91,7 @@ jobs:
9191
runs-on: ubuntu-latest
9292
steps:
9393
- name: Create deploy-bucket
94-
uses: bitovi/[email protected].3
94+
uses: bitovi/[email protected].7
9595
with:
9696
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
9797
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
@@ -106,6 +106,7 @@ jobs:
106106

107107
aws_site_cdn_enabled: true
108108
aws_site_cdn_custom_error_codes: '[{\"error_caching_min_ttl\":\"0\",\"error_code\":\"403\",\"response_code\":\"200\",\"response_page_path\":\"/index.html\"},{\"error_caching_min_ttl\":\"0\",\"error_code\":\"404\",\"response_code\":\"404\",\"response_page_path\":\"/custom_404.html\"}]'
109+
aws_site_cdn_response_headers_policy_id: "eaab4381-ed33-4a86-88ca-d9558dc6cd63"
109110

110111
aws_r53_domain_name: bitovi-sandbox.com
111112
aws_r53_sub_domain_name: catalog-mfe
@@ -117,7 +118,7 @@ jobs:
117118
runs-on: ubuntu-latest
118119
steps:
119120
- name: Create deploy-bucket
120-
uses: bitovi/[email protected].3
121+
uses: bitovi/[email protected].7
121122
with:
122123
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
123124
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
@@ -195,6 +196,7 @@ The following inputs can be used as `step.with` keys
195196
| `aws_site_cdn_enabled` | Boolean | Enable or disables the use of CDN. Defaults to `false`. |
196197
| `aws_site_cdn_aliases` | String | Extra CNAMEs (alternate domain names), if any, for this distribution. Defaults to defined domain if none passed. (See note). |
197198
| `aws_site_cdn_custom_error_codes` | JSON | Custom error codes to define in CDN. Like `[{\"error_caching_min_ttl\":\"0\",\"error_code\":\"403\",\"response_code\":\"200\",\"response_page_path\":\"/index.html\"}]`. See [this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_distribution.html#custom-error-response-arguments). |
199+
| `aws_site_cdn_response_headers_policy_id` | String | Comma separated list of response headers policy IDs for CloudFront. Eg. `Managed-CORS-with-preflight-and-SecurityHeadersPolicy` is `eaab4381-ed33-4a86-88ca-d9558dc6cd63`. |
198200
<hr/>
199201
<br/>
200202

action.yaml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ inputs:
7373
aws_site_cdn_custom_error_codes:
7474
description: 'Customize error codes, Definition done with JSON variables'
7575
required: false
76+
aws_site_cdn_response_headers_policy_id:
77+
description: 'Comma separated list of response headers policy IDs for CloudFront. Eg. Managed-CORS-with-preflight-and-SecurityHeadersPolicy is 67f7725c-6f97-4210-82d7-5512b31e9d42.'
78+
required: false
7679

7780
# AWS Route53 Domains and Certificates
7881
aws_r53_domain_name:
@@ -136,6 +139,7 @@ runs:
136139
AWS_SITE_CDN_ENABLED: ${{ inputs.aws_site_cdn_enabled }}
137140
AWS_SITE_CDN_ALIASES: ${{ inputs.aws_site_cdn_aliases }}
138141
AWS_SITE_CDN_CUSTOM_ERROR_CODES: ${{ inputs.aws_site_cdn_custom_error_codes }}
142+
AWS_SITE_CDN_RESPONSE_HEADERS_POLICY_ID: ${{ inputs.aws_site_cdn_response_headers_policy_id }}
139143
# AWS Route53 Domains abd Certificates
140144
AWS_R53_DOMAIN_NAME: ${{ inputs.aws_r53_domain_name }}
141145
AWS_R53_SUB_DOMAIN_NAME: ${{ inputs.aws_r53_sub_domain_name }}
@@ -209,7 +213,7 @@ runs:
209213
if: ${{ success() && steps.apply.outputs.public_url != '' }}
210214
shell: bash
211215
run: |
212-
echo "## It's published! :rocket:" >> $GITHUB_STEP_SUMMARY
216+
echo "# It's published! :rocket:" >> $GITHUB_STEP_SUMMARY
213217
echo ${{ steps.apply.outputs.public_url }} >> $GITHUB_STEP_SUMMARY
214218
215219
- name: Print result
@@ -233,3 +237,15 @@ runs:
233237
echo "## Workflow failed to run :fire:" >> $GITHUB_STEP_SUMMARY
234238
echo "Please check the logs for possible errors." >> $GITHUB_STEP_SUMMARY
235239
echo "If you consider this is a bug in the Github Action, please submit an issue to our repo." >> $GITHUB_STEP_SUMMARY
240+
241+
- name: Print footer
242+
if: ${{ success() && steps.apply.outputs.public_url != '' }}
243+
shell: bash
244+
run: |
245+
echo "" >> $GITHUB_STEP_SUMMARY
246+
echo "---" >> $GITHUB_STEP_SUMMARY
247+
echo "# Made by [![Bitovi](https://www.bitovi.com/hubfs/limbo-generated/imgs/logos/bitovi-logo-23.svg)](https://bitovi.com)" >> $GITHUB_STEP_SUMMARY
248+
echo "" >> $GITHUB_STEP_SUMMARY
249+
echo "Check the rest of our actions in the [GitHub Marketplace](https://github.com/marketplace?category=&type=actions&verification=&query=bitovi)!" >> $GITHUB_STEP_SUMMARY
250+
echo "" >> $GITHUB_STEP_SUMMARY
251+
echo "You can get help or ask questions on our [Discord Channel](https://discord.gg/J7ejFsZnJ4Z), or set up a free consultation on our [platform engineering website](https://www.bitovi.com/services/devops-consulting/platform-engineering)." >> $GITHUB_STEP_SUMMARY

scripts/generate_deploy.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ aws_site_bucket_name=$(generate_var aws_site_bucket_name $AWS_SITE_BUCKET_NAME)
9797
aws_site_cdn_enabled=$(generate_var aws_site_cdn_enabled $AWS_SITE_CDN_ENABLED)
9898
aws_site_cdn_aliases=$(generate_var aws_site_cdn_aliases $AWS_SITE_CDN_ALIASES)
9999
aws_site_cdn_custom_error_codes=$(generate_var aws_site_cdn_custom_error_codes $AWS_SITE_CDN_CUSTOM_ERROR_CODES)
100+
aws_site_cdn_response_headers_policy_id=$(generate_var aws_site_cdn_response_headers_policy_id $AWS_SITE_CDN_RESPONSE_HEADERS_POLICY_ID)
100101
aws_site_root_object=$(generate_var aws_site_root_object $AWS_SITE_ROOT_OBJECT)
101102
aws_site_error_document=$(generate_var aws_site_error_document $AWS_SITE_ERROR_DOCUMENT)
102103
aws_r53_domain_name=$(generate_var aws_r53_domain_name $AWS_R53_DOMAIN_NAME)
@@ -119,6 +120,7 @@ $aws_site_bucket_name
119120
$aws_site_cdn_enabled
120121
$aws_site_cdn_aliases
121122
$aws_site_cdn_custom_error_codes
123+
$aws_site_cdn_response_headers_policy_id
122124
$aws_site_root_object
123125
$aws_site_error_document
124126
$aws_r53_domain_name

terraform_code/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ resource "aws_s3_bucket_policy" "aws_site_website_bucket_policy" {
135135

136136
### CDN
137137

138+
locals {
139+
aws_site_cdn_response_headers_policy_id = var.aws_site_cdn_response_headers_policy_id != "" ? [
140+
for n in split(",", var.aws_site_cdn_response_headers_policy_id) : (n)
141+
] : []
142+
}
143+
138144
### CDN Without DNS
139145
resource "aws_cloudfront_distribution" "cdn_static_site_default_cert" {
140146
count = var.aws_site_cdn_enabled ? ( local.cert_available ? 0 : 1 ) : 0
@@ -165,6 +171,7 @@ resource "aws_cloudfront_distribution" "cdn_static_site_default_cert" {
165171
forward = "none"
166172
}
167173
}
174+
response_headers_policy_id = length(local.aws_site_cdn_response_headers_policy_id) > 0 ? local.aws_site_cdn_response_headers_policy_id[0] : null
168175
}
169176

170177
restrictions {
@@ -220,6 +227,7 @@ resource "aws_cloudfront_distribution" "cdn_static_site" {
220227
forward = "none"
221228
}
222229
}
230+
response_headers_policy_id = length(local.aws_site_cdn_response_headers_policy_id) > 0 ? local.aws_site_cdn_response_headers_policy_id[0] : null
223231
}
224232

225233
restrictions {

terraform_code/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ variable "aws_site_cdn_custom_error_codes" {
6161
default = "{}"
6262
}
6363

64+
variable "aws_site_cdn_response_headers_policy_id" {
65+
description = "Comma separated list of response headers policy IDs for CloudFront."
66+
type = string
67+
default = ""
68+
}
69+
6470
variable "aws_r53_domain_name" {
6571
description = "root domain name without any subdomains"
6672
type = string

0 commit comments

Comments
 (0)