Skip to content

Commit

Permalink
fix: Fix potential conflict between tailscale install & AWS startup a…
Browse files Browse the repository at this point in the history
…ctivity (#18)

fix: Fix potential conflict during tailscale install
  • Loading branch information
Hawxy authored Aug 17, 2023
1 parent 3bc9aff commit d4b4eff
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ export class TailscaleBastion extends Construct {

// Install Tailscale
InitCommand.shellCommand('dnf config-manager --add-repo https://pkgs.tailscale.com/stable/amazon-linux/2023/tailscale.repo'),
InitCommand.shellCommand('dnf -y install tailscale'),
// Protect against a potential conflict with AWS activity
InitCommand.shellCommand('sleep 10'),
InitCommand.shellCommand('dnf -y install jq'),
InitCommand.shellCommand('dnf -y install tailscale'),
InitCommand.shellCommand('systemctl enable --now tailscaled'),
InitCommand.shellCommand(`echo TS_AUTHKEY=${authKeyCommand} >> /etc/environment`),
InitCommand.shellCommand(`source /etc/environment && tailscale up --authkey $TS_AUTHKEY --advertise-routes=${advertiseRoute ?? vpc.vpcCidrBlock} --accept-routes --accept-dns=false`),
Expand Down
9 changes: 6 additions & 3 deletions test/construct.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,18 @@ test('Bastion host should be created', () => {
command: 'dnf config-manager --add-repo https://pkgs.tailscale.com/stable/amazon-linux/2023/tailscale.repo',
},
'007': {
command: 'dnf -y install tailscale',
command: 'sleep 10',
},
'008': {
command: 'dnf -y install jq',
},
'009': {
command: 'systemctl enable --now tailscaled',
command: 'dnf -y install tailscale',
},
'010': {
command: 'systemctl enable --now tailscaled',
},
'011': {
command: {
'Fn::Join': [
'',
Expand All @@ -94,7 +97,7 @@ test('Bastion host should be created', () => {
],
},
},
'011': {
'012': {
command: {
'Fn::Join': [
'',
Expand Down
2 changes: 1 addition & 1 deletion test/routes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ test('Bastion host should have routing set up', () => {
'AWS::CloudFormation::Init': {
config: {
commands: {
'011': {
'012': {
command: 'source /etc/environment && tailscale up --authkey $TS_AUTHKEY --advertise-routes=fd7a:115c:a1e0:b1a:0:7:a01:100/120 --accept-routes --accept-dns=false',
},
},
Expand Down

0 comments on commit d4b4eff

Please sign in to comment.