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

fix: Spinwait tailscale install to protect against SSM conflicts #24

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 1 addition & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ export class TailscaleBastion extends Construct {
// Install Tailscale
InitCommand.shellCommand('dnf config-manager --add-repo https://pkgs.tailscale.com/stable/amazon-linux/2023/tailscale.repo'),
// 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('until dnf -y install tailscale ; do sleep 10s ; done'),
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
12 changes: 3 additions & 9 deletions test/construct.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,12 @@ test('Bastion host should be created', () => {
command: 'dnf config-manager --add-repo https://pkgs.tailscale.com/stable/amazon-linux/2023/tailscale.repo',
},
'007': {
command: 'sleep 10',
command: 'until dnf -y install tailscale ; do sleep 10s ; done',
},
'008': {
command: 'dnf -y install jq',
},
'009': {
command: 'dnf -y install tailscale',
},
'010': {
command: 'systemctl enable --now tailscaled',
},
'011': {
'009': {
command: {
'Fn::Join': [
'',
Expand All @@ -97,7 +91,7 @@ test('Bastion host should be created', () => {
],
},
},
'012': {
'010': {
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: {
'012': {
'010': {
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