-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d80af2a
commit ef52eb1
Showing
3,163 changed files
with
120,281 additions
and
0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test.zip | ||
.vscode | ||
.history |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"esversion" : 6 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: 'Gross Cloud Network EBS Production' | ||
description: 'Configure aws eb environment variables' | ||
author: 'Gross Corporation' | ||
runs: | ||
using: 'node12' | ||
main: 'env.js' | ||
inputs: | ||
aws_access_key: | ||
description: 'AWS Access Key' | ||
required: true | ||
aws_secret_key: | ||
description: 'AWS Secret Key' | ||
required: true | ||
environment: | ||
description: 'Node environment variable' | ||
required: true | ||
secret_name: | ||
description: 'Secret name' | ||
required: true | ||
slug: | ||
description: 'Custom app slug for variants' | ||
required: true | ||
region: | ||
description: 'AWS Region' | ||
required: true | ||
|
||
branding: | ||
icon: 'arrow-up' | ||
color: 'green' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/bin/bash | ||
|
||
# Check if jq is installed | ||
if ! command -v jq &> /dev/null; then | ||
echo "jq is required but it's not installed. Install jq and try again." | ||
exit 1 | ||
fi | ||
|
||
# Set default region | ||
REGION=${INPUT_REGION:-${AWS_REGION:-us-east-1}} | ||
|
||
# Set secret name | ||
SECRET_NAME=${INPUT_SECRET_NAME:-${SECRET_NAME}} | ||
|
||
# Load environment variables from .env if it exists | ||
if [ -f .env ]; then | ||
export $(cat .env | xargs) | ||
fi | ||
|
||
# Check if running in GitHub Actions | ||
IS_GITHUB_ACTION=${GITHUB_ACTIONS:-false} | ||
|
||
# Application name or slug | ||
APP_NAME=${1:-${INPUT_SLUG}} | ||
|
||
# Logging function | ||
log() { | ||
echo '###############################################################' | ||
echo "$1" | ||
echo '###############################################################' | ||
} | ||
|
||
log "APP_SLUG ENV ~ $APP_NAME" | ||
log "REGION ~ $REGION" | ||
log "SECRET NAME ~ $SECRET_NAME" | ||
|
||
# Fetch secrets from AWS Secrets Manager | ||
fetch_secrets() { | ||
aws secretsmanager get-secret-value --region "$REGION" --secret-id "$SECRET_NAME" --query SecretString --output text | ||
} | ||
|
||
# Process and write secrets to files | ||
process_secrets() { | ||
local secrets_json | ||
secrets_json=$(fetch_secrets) | ||
if [ -z "$secrets_json" ]; then | ||
echo "Failed to fetch secrets or secret is empty" | ||
exit 1 | ||
fi | ||
|
||
local env_file="" | ||
local eb_file="" | ||
|
||
# Loop through each key-value pair in the JSON | ||
echo "$secrets_json" | jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' | while IFS= read -r line; do | ||
key=$(echo $line | cut -d'=' -f1) | ||
value=$(echo $line | cut -d'=' -f2) | ||
env_file+="${key}=${value}\n" | ||
eb_file+=" ${key}: ${value}\n" | ||
done | ||
|
||
local eb_map="option_settings: | ||
aws:elasticbeanstalk:application:environment: | ||
$eb_file" | ||
|
||
if [ "$IS_GITHUB_ACTION" = true ]; then | ||
echo -e "$eb_map" > ./.ebextensions/options.config | ||
echo -e "$env_file" > ./.env | ||
log "GITHUB_ACTION EB ~ $APP_NAME" | ||
fi | ||
} | ||
|
||
# Main execution | ||
process_secrets | ||
|
||
# Dummy wait to replicate original JavaScript delay | ||
sleep 5 | ||
|
||
echo "done" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/usr/bin/env node// Author: Gross Corporation, https://github.com/grosscorporation/eb-environment-variables | ||
|
||
|
||
|
||
const { SecretsManager } = require('@aws-sdk/client-secrets-manager'); | ||
|
||
let fs = require('fs') | ||
try { | ||
if (process.env.NODE_ENV === 'development') { | ||
require('dotenv').config({ path: process.cwd() + '/.env' }) | ||
} | ||
} catch (e) {} | ||
|
||
const IS_GITHUB_ACTION = !!process.env.GITHUB_ACTIONS | ||
|
||
const appName = process.argv.splice(2)[0] || process.env.INPUT_SLUG | ||
const region = process.env.INPUT_REGION || 'eu-west-1' | ||
|
||
const secretName = process.env.INPUT_SECRET_NAME | ||
const releaseTag = process.env.INPUT_RELEASE_TAG || (new Date() * 1000).toString() | ||
|
||
console.log('###############################################################') | ||
console.log('APP_SLUG ENV ~ ', appName) | ||
console.log('###############################################################') | ||
|
||
console.log('###############################################################') | ||
console.log('REGION ~ ', region) | ||
console.log('###############################################################') | ||
|
||
console.log('###############################################################') | ||
console.log('RELEASE TAG ~ ', releaseTag) | ||
console.log('###############################################################') | ||
|
||
console.log('###############################################################') | ||
console.log('SECRET NAME ~ ', secretName) | ||
console.log('###############################################################') | ||
|
||
const awsConfig = { | ||
region, | ||
accessKeyId: process.env.INPUT_AWS_ACCESS_KEY || process.env.AWS_ACCESS_KEY_ID, | ||
secretAccessKey: process.env.INPUT_AWS_SECRET_KEY || process.env.AWS_SECRET_ACCESS_KEY | ||
} | ||
|
||
const client = new SecretsManager(awsConfig) | ||
|
||
client.getSecretValue({ SecretId: secretName }, (err, data) => { | ||
if (err) { | ||
throw err | ||
} else { | ||
if ('SecretString' in data) { | ||
const secrets = JSON.parse(data.SecretString) | ||
secrets.CURRENT_RELEASE = releaseTag | ||
|
||
let envFile = '' | ||
let ebFile = '' | ||
for (const key of Object.keys(secrets)) { | ||
envFile += `${key}=${secrets[key]}\n` | ||
ebFile += ` ${key}: ${secrets[key]}\n` | ||
} | ||
|
||
const ebMap = `option_settings: | ||
aws:elasticbeanstalk:application:environment: | ||
${ebFile}` | ||
|
||
if (IS_GITHUB_ACTION) { | ||
fs.writeFileSync('./.ebextensions/options.config', ebMap, function (err) { | ||
if (err) { | ||
throw err | ||
} else { | ||
console.log('###############################################################') | ||
console.log('GITHUB_ACTION EB ~ ', appName) | ||
console.log('###############################################################') | ||
} | ||
}) | ||
} | ||
} | ||
} | ||
}) | ||
|
||
setTimeout(() => {}, 5000) | ||
|
||
return 'done' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.