<commit_before>#!/bin/bash
#
# Init variables and sanity checks
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
ROOT_DIR=$(dirname $DIR)
BUILD=${BUILD:-$ROOT_DIR/build}

AWS_PROFILE=${AWS_PROFILE:-coreos-cluster}
CLUSTER_NAME=${CLUSTER_NAME:-coreos-cluster}

TF_VAR_aws_access_key=$($DIR/read_cfg.sh $HOME/.aws/credentials $AWS_PROFILE aws_access_key_id)
TF_VAR_aws_secret_key=$($DIR/read_cfg.sh $HOME/.aws/credentials $AWS_PROFILE aws_secret_access_key)
TF_VAR_aws_region=$($DIR/read_cfg.sh $HOME/.aws/config "profile $AWS_PROFILE" region)
aws_user=$(aws --profile $AWS_PROFILE iam get-user)
TF_VAR_aws_account=$(echo $aws_user | jq ".User.Arn" | grep -Eo '[[:digit:]]{12}')
TF_VAR_aws_user=$(echo $aws_user | jq --raw-output '.User.UserName')

cat <<EOF
# Generated by scripts/gen-provider.sh
provider "aws" {
  access_key = "$TF_VAR_aws_access_key"
  secret_key = "$TF_VAR_aws_secret_key"
  region = "$TF_VAR_aws_region"
  max_retries = 3
EOF
if [ ! -z $ALLOWED_ACCOUNT_IDS ]; then
    echo  \ \ allowed_account_ids = [ "$ALLOWED_ACCOUNT_IDS" ]
elif [[ ! -z $FORBIDDEN_ACCOUNT_IDS ]]; then
    echo  \ \ forbidden_account_ids = [ "$FORBIDDEN_ACCOUNT_IDS" ]
fi
cat <<EOF
}
variable "aws_account" {
    default = {
        id = "$TF_VAR_aws_account"
        user = "$TF_VAR_aws_user"
        default_region = "$TF_VAR_aws_region"
    }
}
variable "cluster_name" {
    default = "${CLUSTER_NAME}"
}
variable "build_dir" {
    default = "${BUILD}"
}
EOF<commit_msg>Update gen-provider.sh<commit_after>#!/bin/bash
#
# Init variables and sanity checks
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
ROOT_DIR=$(dirname $DIR)
BUILD=${BUILD:-$ROOT_DIR/build}

AWS_PROFILE=${AWS_PROFILE:-coreos-cluster}
CLUSTER_NAME=${CLUSTER_NAME:-coreos-cluster}

TF_VAR_aws_region=$($DIR/read_cfg.sh $HOME/.aws/config "profile $AWS_PROFILE" region)
aws_user=$(aws --profile $AWS_PROFILE iam get-user)
TF_VAR_aws_account=$(echo $aws_user | jq ".User.Arn" | grep -Eo '[[:digit:]]{12}')
TF_VAR_aws_user=$(echo $aws_user | jq --raw-output '.User.UserName')

cat <<EOF
# Generated by scripts/gen-provider.sh
provider "aws" {
  profile = "$AWS_PROFILE"
  region = "$TF_VAR_aws_region"
  max_retries = 3
EOF
if [ ! -z $ALLOWED_ACCOUNT_IDS ]; then
    echo  \ \ allowed_account_ids = [ "$ALLOWED_ACCOUNT_IDS" ]
elif [[ ! -z $FORBIDDEN_ACCOUNT_IDS ]]; then
    echo  \ \ forbidden_account_ids = [ "$FORBIDDEN_ACCOUNT_IDS" ]
fi
cat <<EOF
}
variable "aws_account" {
    default = {
        id = "$TF_VAR_aws_account"
        user = "$TF_VAR_aws_user"
        default_region = "$TF_VAR_aws_region"
    }
}
variable "cluster_name" {
    default = "${CLUSTER_NAME}"
}
variable "build_dir" {
    default = "${BUILD}"
}
EOF
{'fraction_non_alphanumeric': 0.16, 'fraction_numerical': 0.002962962962962963, 'mean_word_length': 4.710359408033827, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7213368', 'n_tokens_mistral': 1071, 'n_tokens_neox': 1044, 'n_words': 184}