Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added VPC-ID Functionality #105

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions scripts/create-v2-sg-rule-imports.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ set -euxo pipefail

name_prefix="${1-}"
mesh_env="${2-}"
vpc_id="${3-}"



function usage() {
Expand All @@ -23,16 +25,21 @@ if [[ "${mesh_env}" != "production" && "${mesh_env}" != "integration" ]]; then
exit 1
fi

if [[ -z "${vpc_id}" ]]; then
echo "VPC ID not supplied. Please provide a valid VPC ID."
exit 1
fi

sg_check_send="${name_prefix}-mesh-check-send-parameters"
sg_fetch_chunk="${name_prefix}-mesh-fetch-message-chunk"
sg_poll_mailbox="${name_prefix}-mesh-poll-mailbox"
sg_send_chunk="${name_prefix}-mesh-send-message-chunk"


sg_check_send_id="$(aws ec2 describe-security-groups --group-names="${sg_check_send}" --query=SecurityGroups[0].GroupId --output text)"
sg_fetch_chunk_id="$(aws ec2 describe-security-groups --group-names="${sg_fetch_chunk}" --query=SecurityGroups[0].GroupId --output text)"
sg_poll_mailbox_id="$(aws ec2 describe-security-groups --group-names="${sg_poll_mailbox}" --query=SecurityGroups[0].GroupId --output text)"
sg_send_chunk_id="$(aws ec2 describe-security-groups --group-names="${sg_send_chunk}" --query=SecurityGroups[0].GroupId --output text)"
sg_check_send_id="$(aws ec2 describe-security-groups --filters "Name=vpc-id,Values=${vpc_id}" "Name=group-name,Values=${sg_check_send}" --query=SecurityGroups[0].GroupId --output text)"
sg_fetch_chunk_id="$(aws ec2 describe-security-groups --filters "Name=vpc-id,Values=${vpc_id}" "Name=group-name,Values=${sg_fetch_chunk}" --query=SecurityGroups[0].GroupId --output text)"
sg_poll_mailbox_id="$(aws ec2 describe-security-groups --filters "Name=vpc-id,Values=${vpc_id}" "Name=group-name,Values=${sg_poll_mailbox}" --query=SecurityGroups[0].GroupId --output text)"
sg_send_chunk_id="$(aws ec2 describe-security-groups --filters "Name=vpc-id,Values=${vpc_id}" "Name=group-name,Values=${sg_send_chunk}" --query=SecurityGroups[0].GroupId --output text)"

echo "
found sg ids:
Expand Down Expand Up @@ -68,12 +75,12 @@ if [[ "${mesh_env}" == "integration" ]]; then
fi


ssm_sg_id="$(aws ec2 describe-vpc-endpoints --filters=Name=service-name,Values=com.amazonaws.eu-west-2.ssm --query=VpcEndpoints[0].Groups[0].GroupId --output text)"
sfn_sg_id="$(aws ec2 describe-vpc-endpoints --filters=Name=service-name,Values=com.amazonaws.eu-west-2.states --query=VpcEndpoints[0].Groups[0].GroupId --output text)"
logs_sg_id="$(aws ec2 describe-vpc-endpoints --filters=Name=service-name,Values=com.amazonaws.eu-west-2.logs --query=VpcEndpoints[0].Groups[0].GroupId --output text)"
kms_sg_id="$(aws ec2 describe-vpc-endpoints --filters=Name=service-name,Values=com.amazonaws.eu-west-2.kms --query=VpcEndpoints[0].Groups[0].GroupId --output text)"
lambda_sg_id="$(aws ec2 describe-vpc-endpoints --filters=Name=service-name,Values=com.amazonaws.eu-west-2.lambda --query=VpcEndpoints[0].Groups[0].GroupId --output text)"
secrets_sg_id="$(aws ec2 describe-vpc-endpoints --filters=Name=service-name,Values=com.amazonaws.eu-west-2.secretsmanager --query=VpcEndpoints[0].Groups[0].GroupId --output text)"
ssm_sg_id="$(aws ec2 describe-vpc-endpoints --filters=Name=service-name,Values=com.amazonaws.eu-west-2.ssm --query=VpcEndpoints[0].Groups[0].GroupId --filters=Name=vpc-id,Values="${vpc_id}" --output text)"
sfn_sg_id="$(aws ec2 describe-vpc-endpoints --filters=Name=service-name,Values=com.amazonaws.eu-west-2.states --query=VpcEndpoints[0].Groups[0].GroupId --filters=Name=vpc-id,Values="${vpc_id}" --output text)"
logs_sg_id="$(aws ec2 describe-vpc-endpoints --filters=Name=service-name,Values=com.amazonaws.eu-west-2.logs --query=VpcEndpoints[0].Groups[0].GroupId --filters=Name=vpc-id,Values="${vpc_id}" --output text)"
kms_sg_id="$(aws ec2 describe-vpc-endpoints --filters=Name=service-name,Values=com.amazonaws.eu-west-2.kms --query=VpcEndpoints[0].Groups[0].GroupId --filters=Name=vpc-id,Values="${vpc_id}" --output text)"
lambda_sg_id="$(aws ec2 describe-vpc-endpoints --filters=Name=service-name,Values=com.amazonaws.eu-west-2.lambda --query=VpcEndpoints[0].Groups[0].GroupId --filters=Name=vpc-id,Values="${vpc_id}" --output text)"
secrets_sg_id="$(aws ec2 describe-vpc-endpoints --filters=Name=service-name,Values=com.amazonaws.eu-west-2.secretsmanager --query=VpcEndpoints[0].Groups[0].GroupId --filters=Name=vpc-id,Values="${vpc_id}" --output text)"



Expand Down