Skip to content

Commit

Permalink
[Improvement] * - Enable in-transit encryption on EFS mounts (widdix#335
Browse files Browse the repository at this point in the history
)
  • Loading branch information
michaelwittig authored Jul 30, 2019
1 parent 6a04229 commit 732f76d
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 47 deletions.
38 changes: 17 additions & 21 deletions jenkins/jenkins2-ha-agents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -848,42 +848,39 @@ Resources:
commands:
- 'a_configure_sshd_command'
- 'b_configure_sshd_commanduser'
extras:
commands:
'a_enable_docker':
command: 'amazon-linux-extras enable docker=18.06.1'
test: "! grep -Fxq '[amzn2extra-docker]' /etc/yum.repos.d/amzn2-extras.repo"
'b_enable_corretto8':
command: 'amazon-linux-extras enable corretto8'
test: "! grep -Fxq '[amzn2extra-corretto8]' /etc/yum.repos.d/amzn2-extras.repo"
mount:
packages:
yum:
'nfs-utils': []
'ruby': []
rubygems:
'aws-sdk-autoscaling': ['1.13.0']
'aws-sdk-sqs': ['1.10.0']
daemons: ['1.2.6']
'amazon-efs-utils': []
commands:
'a_groupadd':
command: 'groupadd -g 497 jenkins'
test: 'if grep -q jenkins: /etc/group; then exit 1; else exit 0; fi'
'b_useradd':
command: 'adduser -u 498 -g 497 -s /bin/false -d /var/lib/jenkins -c ''Jenkins Continuous Integration Server'' jenkins'
command: 'adduser -u 498 -g 497 -s /bin/false -d /var/lib/jenkins -M -c ''Jenkins Continuous Integration Server'' jenkins'
test: 'if grep -q jenkins: /etc/passwd; then exit 1; else exit 0; fi'
'c_mountpoint_mkdir':
command: 'mkdir /var/lib/jenkins && chown -R jenkins:jenkins /var/lib/jenkins'
'c_mount':
command: !Sub 'mkdir /var/lib/jenkins && chown -R jenkins:jenkins /var/lib/jenkins && echo "${MasterStorage}:/ /var/lib/jenkins efs tls,_netdev 0 0" >> /etc/fstab && mount -a -t efs'
test: '[ ! -d /var/lib/jenkins ]'
'd_mountpoint_mount':
command: !Sub 'while ! (echo > /dev/tcp/${MasterStorage}.efs.${AWS::Region}.amazonaws.com/2049) >/dev/null 2>&1; do sleep 10; done && sleep 10 && mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 "${MasterStorage}.efs.${AWS::Region}.amazonaws.com:/" /var/lib/jenkins'
test: 'if mount | grep -q /var/lib/jenkins; then exit 1; else exit 0; fi'
extras:
commands:
'a_enable_docker':
command: 'amazon-linux-extras enable docker=18.06.1'
test: "! grep -Fxq '[amzn2extra-docker]' /etc/yum.repos.d/amzn2-extras.repo"
'b_enable_corretto8':
command: 'amazon-linux-extras enable corretto8'
test: "! grep -Fxq '[amzn2extra-corretto8]' /etc/yum.repos.d/amzn2-extras.repo"
install:
packages:
rpm:
jenkins: 'https://pkg.jenkins.io/redhat-stable/jenkins-2.176.2-1.1.noarch.rpm'
yum:
'java-1.8.0-amazon-corretto': []
'ruby': []
rubygems:
'aws-sdk-autoscaling': ['1.13.0']
'aws-sdk-sqs': ['1.10.0']
daemons: ['1.2.6']
files:
'/etc/cfn/cfn-hup.conf':
content: !Sub |
Expand Down Expand Up @@ -1758,7 +1755,6 @@ Resources:
setup:
packages:
yum:
'nfs-utils': []
'ruby': []
rubygems:
'aws-sdk-autoscaling': ['1.13.0']
Expand Down
27 changes: 12 additions & 15 deletions jenkins/jenkins2-ha.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -752,31 +752,28 @@ Resources:
commands:
- 'a_configure_sshd_command'
- 'b_configure_sshd_commanduser'
extras:
commands:
'a_enable_docker':
command: 'amazon-linux-extras enable docker=18.06.1'
test: "! grep -Fxq '[amzn2extra-docker]' /etc/yum.repos.d/amzn2-extras.repo"
'b_enable_corretto8':
command: 'amazon-linux-extras enable corretto8=1.8.0_202'
test: "! grep -Fxq '[amzn2extra-corretto8]' /etc/yum.repos.d/amzn2-extras.repo"
mount:
packages:
yum:
'nfs-utils': []
'amazon-efs-utils': []
commands:
'a_groupadd':
command: 'groupadd -g 497 jenkins'
test: 'if grep -q jenkins: /etc/group; then exit 1; else exit 0; fi'
'b_useradd':
command: 'adduser -u 498 -g 497 -s /bin/false -d /var/lib/jenkins -c ''Jenkins Continuous Integration Server'' jenkins'
command: 'adduser -u 498 -g 497 -s /bin/false -d /var/lib/jenkins -M -c ''Jenkins Continuous Integration Server'' jenkins'
test: 'if grep -q jenkins: /etc/passwd; then exit 1; else exit 0; fi'
'c_mountpoint_mkdir':
command: 'mkdir /var/lib/jenkins && chown -R jenkins:jenkins /var/lib/jenkins'
'c_mount':
command: !Sub 'mkdir /var/lib/jenkins && chown -R jenkins:jenkins /var/lib/jenkins && echo "${MasterStorage}:/ /var/lib/jenkins efs tls,_netdev 0 0" >> /etc/fstab && mount -a -t efs'
test: '[ ! -d /var/lib/jenkins ]'
'd_mountpoint_mount':
command: !Sub 'while ! (echo > /dev/tcp/${MasterStorage}.efs.${AWS::Region}.amazonaws.com/2049) >/dev/null 2>&1; do sleep 10; done && sleep 10 && mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 "${MasterStorage}.efs.${AWS::Region}.amazonaws.com:/" /var/lib/jenkins'
test: 'if mount | grep -q /var/lib/jenkins; then exit 1; else exit 0; fi'
extras:
commands:
'a_enable_docker':
command: 'amazon-linux-extras enable docker=18.06.1'
test: "! grep -Fxq '[amzn2extra-docker]' /etc/yum.repos.d/amzn2-extras.repo"
'b_enable_corretto8':
command: 'amazon-linux-extras enable corretto8=1.8.0_202'
test: "! grep -Fxq '[amzn2extra-corretto8]' /etc/yum.repos.d/amzn2-extras.repo"
install:
packages:
rpm:
Expand Down
2 changes: 1 addition & 1 deletion vpc/vpc-vpn-bastion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ Resources:
'amazon-efs-utils': []
commands:
'a_mount':
command: !Sub 'mkdir /mnt/storage && echo "${Storage} /mnt/storage efs defaults,_netdev 0 0" >> /etc/fstab && mount -a -t efs'
command: !Sub 'mkdir /mnt/storage && echo "${Storage}:/ /mnt/storage efs tls,_netdev 0 0" >> /etc/fstab && mount -a -t efs'
test: '[ ! -d /mnt/storage ]'
'b_mkdir_backup':
command: 'mkdir backup.vpn_server.config && chmod 700 backup.vpn_server.config'
Expand Down
14 changes: 9 additions & 5 deletions wordpress/wordpress-ha-aurora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ Resources:
Metadata:
'AWS::CloudFormation::Init':
configSets:
default: !If [HasIAMUserSSHAccess, [awslogs, ssh-access, extras, config], [awslogs, extras, config]]
default: !If [HasIAMUserSSHAccess, [awslogs, ssh-access, mount, extras, config], [awslogs, mount, extras, config]]
awslogs:
packages:
yum:
Expand Down Expand Up @@ -826,6 +826,14 @@ Resources:
commands:
- 'a_configure_sshd_command'
- 'b_configure_sshd_commanduser'
mount:
packages:
yum:
'amazon-efs-utils': []
commands:
'a_mount':
command: !Sub 'mkdir /var/www && echo "${EFSFileSystem}:/ /var/www efs tls,_netdev 0 0" >> /etc/fstab && mount -a -t efs'
test: '[ ! -d /var/www ]'
extras:
commands:
'a_enable_php':
Expand Down Expand Up @@ -932,10 +940,6 @@ Resources:
'Fn::Base64': !Sub |
#!/bin/bash -ex
trap '/opt/aws/bin/cfn-signal -e 1 --stack ${AWS::StackName} --resource AutoScalingGroup --region ${AWS::Region}' ERR
while ! (echo > /dev/tcp/${EFSFileSystem}.efs.${AWS::Region}.amazonaws.com/2049) >/dev/null 2>&1; do sleep 10; done
sleep 10
mkdir /var/www
mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 "${EFSFileSystem}.efs.${AWS::Region}.amazonaws.com:/" /var/www/
/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource LaunchConfiguration --region ${AWS::Region}
/opt/aws/bin/cfn-signal -e 0 --stack ${AWS::StackName} --resource AutoScalingGroup --region ${AWS::Region}
AutoScalingGroup:
Expand Down
14 changes: 9 additions & 5 deletions wordpress/wordpress-ha.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ Resources:
Metadata:
'AWS::CloudFormation::Init':
configSets:
default: !If [HasIAMUserSSHAccess, [awslogs, ssh-access, extras, config], [awslogs, extras, config]]
default: !If [HasIAMUserSSHAccess, [awslogs, ssh-access, mount, extras, config], [awslogs, mount, extras, config]]
awslogs:
packages:
yum:
Expand Down Expand Up @@ -811,6 +811,14 @@ Resources:
commands:
- 'a_configure_sshd_command'
- 'b_configure_sshd_commanduser'
mount:
packages:
yum:
'amazon-efs-utils': []
commands:
'a_mount':
command: !Sub 'mkdir /var/www && echo "${EFSFileSystem}:/ /var/www efs tls,_netdev 0 0" >> /etc/fstab && mount -a -t efs'
test: '[ ! -d /var/www ]'
extras:
commands:
'a_enable_php':
Expand Down Expand Up @@ -917,10 +925,6 @@ Resources:
'Fn::Base64': !Sub |
#!/bin/bash -ex
trap '/opt/aws/bin/cfn-signal -e 1 --stack ${AWS::StackName} --resource AutoScalingGroup --region ${AWS::Region}' ERR
while ! (echo > /dev/tcp/${EFSFileSystem}.efs.${AWS::Region}.amazonaws.com/2049) >/dev/null 2>&1; do sleep 10; done
sleep 10
mkdir /var/www
mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 "${EFSFileSystem}.efs.${AWS::Region}.amazonaws.com:/" /var/www/
/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource LaunchConfiguration --region ${AWS::Region}
/opt/aws/bin/cfn-signal -e 0 --stack ${AWS::StackName} --resource AutoScalingGroup --region ${AWS::Region}
AutoScalingGroup:
Expand Down

0 comments on commit 732f76d

Please sign in to comment.