Initial cross-account log sharing module (#176)
This commit is contained in:
1 parent
2c4933346d
commit
0512d6da11
55 files changed
+4193
-1
No files matched your search
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if ! command -v gh >/dev/null 2>&1; then
|
||||
echo "error: GitHub CLI (gh) is required but not installed." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v jq >/dev/null 2>&1; then
|
||||
echo "error: jq is required but not installed." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! gh extension list | awk '{print $1}' | grep -qx "agynio/gh-pr-review"; then
|
||||
echo "Installing gh extension agynio/gh-pr-review..." >&2
|
||||
gh extension install agynio/gh-pr-review
|
||||
fi
|
||||
|
||||
GH_REPO="$(git config --get remote.origin.url | sed 's/.*[:\/]\(.*\)\/\(.*\)\.git/\1\/\2/')"
|
||||
GIT_PR="$(gh pr list --head "$(git branch --show-current)" --json number | jq '.[0].number')"
|
||||
|
||||
gh pr-review review view "${GIT_PR}" --repo "${GH_REPO}"
|
||||
@@ -76,5 +76,31 @@ jobs:
|
||||
- name: Validate ${{ matrix.terraform_dir }} module (covers all submodules)
|
||||
working-directory: ${{ matrix.terraform_dir }}
|
||||
run: |
|
||||
# Some modules use aliased AWS providers (for example aws.destination/aws.target)
|
||||
# and fail direct `terraform validate` unless alias configs are present.
|
||||
# Generate a temporary provider file for any discovered aws.<alias> references.
|
||||
AWS_ALIASES="$(grep -RhoE 'provider[[:space:]]*=[[:space:]]*aws\.[A-Za-z0-9_]+' -- *.tf 2>/dev/null | sed -E 's/.*aws\.([A-Za-z0-9_]+)/\1/' | sort -u || true)"
|
||||
if [[ -n "${AWS_ALIASES}" ]]; then
|
||||
# Terraform ignores dot-prefixed files, so this must not start with "."
|
||||
AUTO_PROVIDER_FILE="tfvalidate.providers.auto.tf"
|
||||
{
|
||||
echo "// Generated by CI for terraform validate."
|
||||
echo "// Do not commit."
|
||||
echo
|
||||
} > "${AUTO_PROVIDER_FILE}"
|
||||
|
||||
for alias in ${AWS_ALIASES}; do
|
||||
{
|
||||
echo 'provider "aws" {'
|
||||
echo " alias = \"${alias}\""
|
||||
echo ' region = "us-east-2"'
|
||||
echo '}'
|
||||
echo
|
||||
} >> "${AUTO_PROVIDER_FILE}"
|
||||
done
|
||||
|
||||
echo "Generated ${AUTO_PROVIDER_FILE} for aliases: ${AWS_ALIASES}"
|
||||
fi
|
||||
|
||||
terraform init -backend=false
|
||||
terraform validate
|
||||
Reference in new issue
Block a user