Skip to content

Commit cb0405e

Browse files
authored
Merge pull request #1 from aws-samples/ssm-changes
Upgrade to 1.10.1
2 parents 2edb46f + 055a8bf commit cb0405e

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ This repository assumes you have a new AWS account and wish to test Spinnaker ou
3232
3. Navigate to CodeBuild
3333
4. Start the create-eks CodeBuild project
3434
5. Create a security group in the EKS-VPC to lock-down the Spinnaker load balancers take note of the security group id.
35-
6. Start the deploy-spinnaker CodeBuild project, fill in the environment variable "SECURITY_GROUP_ID" with the security group id from the previous step
35+
6. Start the deploy-spinnaker CodeBuild project, fill in the environment variable "SECURITY_GROUP_ID" with the security group id from the previous step (replacing the "false" default)
3636
3737
Spinnaker will be available at the UI/Deck address emitted at the end of the deploy-spinnaker CodeBuild job.
3838
@@ -55,9 +55,7 @@ Once it is downloaded you can run kubectl commands as normal to read and output
5555

5656
# Exposing Services
5757

58-
See the [buildspec section](#modifying-buildspec-for-authentication-and-security-groups) for some supplemental information.
59-
60-
The code in this repository will create two load balancers using the EKS and EC2 integrations, these services are created in the deploy_spinnaker.sh. When created these load balancers are open to the world, so there are few flags in the deploy_spinnaker.sh to give you options on locking down the security groups, the flags in this example will apply the security group specified in the deploy_spinnaker.sh script to the load balancers to lock down load balancers.
58+
There are two methods in this repository that can expose the Spinnaker services on load balancers, one uses a user-provided security group that is locked down. These are controlled via environment variables in the deploy-spinnaker CodeBuild project. The second method is using SSM to store security information that can be used to lock down the Spinnaker installation even further. See details in the deploy_spinnaker.sh script.
6159

6260
# Modifying the Spinnaker installation
6361

buildspec-deploy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ phases:
1616
- ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
1717
- ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
1818
- aws s3 cp s3://codebuild-artifacts-${ACCOUNT_ID}/create-eks/files/resources/kubernetes/kubeconfig-no-role.yaml /home/spinnaker/.kube/config
19-
- su spinnaker -c "./scripts/deploy_spinnaker.sh -f ${SECURITY_GROUP_ID}"
19+
- su spinnaker -c "./scripts/deploy_spinnaker.sh -S ${USE_SSM} -f ${SECURITY_GROUP_ID}"

resources/cloudformation/codebuild-projects.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ Resources:
120120
-
121121
Name: SECURITY_GROUP_ID
122122
Type: PLAINTEXT
123-
Value: ""
123+
Value: false
124+
-
125+
Name: USE_SSM
126+
Type: PLAINTEXT
127+
Value: false
124128
Name: deploy-spinnaker
125129
ServiceRole: !Ref CreateEKSSpinnakerRole
126130
Source:

scripts/deploy_spinnaker.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ Usage: $0
1515
""" 1>&2; exit 1;
1616
}
1717

18-
while getopts ":Sg:r:f:" o; do
18+
while getopts "S:g:r:f:" o; do
1919
case "${o}" in
2020
S)
21-
USE_SSM_FOR_SECRETS=true
21+
USE_SSM_FOR_SECRETS=${OPTARG}
2222
;;
2323
g)
2424
GITHUB_ORG=${OPTARG}
@@ -46,6 +46,7 @@ if [ -z "${REGION}" ]; then
4646
fi
4747

4848
if [ "${USE_SSM_FOR_SECRETS}" == true ]; then
49+
LB_SG=""
4950
AUTHN_CLIENT_ID=$(aws ssm get-parameters --names github-authn-client-id --with-decryption --query Parameters[0].Value --output text)
5051
AUTHN_CLIENT_SECRET=$(aws ssm get-parameters --names github-authn-client-secret --with-decryption --query Parameters[0].Value --output text)
5152
AUTHZ_ACCESS_TOKEN=$(aws ssm get-parameters --names github-authz-token --with-decryption --query Parameters[0].Value --output text)
@@ -83,10 +84,11 @@ GATE_SG=$(aws elb describe-load-balancers --load-balancer-names ${GATE_LB} --que
8384
DECK_SG=$(aws elb describe-load-balancers --load-balancer-names ${DECK_LB} --query LoadBalancerDescriptions[0].SecurityGroups[0] --output text)
8485

8586
if [ ! -z "${PREFIX_LIST}" ]; then
86-
aws ec2 describe-security-groups --group-ids ${GATE_SG} | grep ${PREFIX_LIST} && echo "Found prefix list, skipping adding exception" || \
87-
aws ec2 authorize-security-group-ingress --group-id ${GATE_SG} --ip-permissions '[{"FromPort":80,"IpProtocol":"tcp","PrefixListIds":[{"Description":"prefix-list-restriction","PrefixListId":"pl-f8a64391"}],"ToPort":80}]'
88-
aws ec2 describe-security-groups --group-ids ${DECK_SG} | grep ${PREFIX_LIST} && echo "Found prefix list, skipping adding exception" || \
89-
aws ec2 authorize-security-group-ingress --group-id ${DECK_SG} --ip-permissions '[{"FromPort":80,"IpProtocol":"tcp","PrefixListIds":[{"Description":"prefix-list-restriction","PrefixListId":"pl-f8a64391"}],"ToPort":80}]'
87+
for SG in "${GATE_SG}" "${DECK_SG}"; do
88+
aws ec2 revoke-security-group-ingress --group-id ${SG} --protocol tcp --port 80 --cidr 0.0.0.0/0 || true
89+
aws ec2 describe-security-groups --group-ids ${SG} | grep ${PREFIX_LIST} && echo "Found prefix list, skipping adding exception" || \
90+
aws ec2 authorize-security-group-ingress --group-id ${SG} --ip-permissions '[{"FromPort":80,"IpProtocol":"tcp","PrefixListIds":[{"Description":"prefix-list-restriction","PrefixListId":"pl-f8a64391"}],"ToPort":80}]'
91+
done
9092
elif [ ! -z "${LB_SG}" ]; then
9193
for LB in "${GATE_LB}" "${DECK_LB}"; do
9294
PREV_GROUPS=$(aws elb describe-load-balancers --load-balancer-names ${LB} --query LoadBalancerDescriptions[0].SecurityGroups[*] --output text | tr "\t" " ")

0 commit comments

Comments
 (0)