From 2d377f7c0d163f552f594087925859c6e4a971c5 Mon Sep 17 00:00:00 2001 From: Mikhail Timofeev Date: Mon, 17 May 2021 13:40:34 +0300 Subject: [PATCH] Move aws-sam-cli installation to the aws.sh script --- .../linux/scripts/installers/aws-sam-cli.sh | 28 ------------------- images/linux/scripts/installers/aws.sh | 9 +++++- .../linux/scripts/tests/CLI.Tools.Tests.ps1 | 2 -- images/linux/toolsets/toolset-1804.json | 4 --- images/linux/toolsets/toolset-2004.json | 4 --- images/linux/ubuntu1604.json | 10 ------- 6 files changed, 8 insertions(+), 49 deletions(-) delete mode 100644 images/linux/scripts/installers/aws-sam-cli.sh diff --git a/images/linux/scripts/installers/aws-sam-cli.sh b/images/linux/scripts/installers/aws-sam-cli.sh deleted file mode 100644 index 4fbaa36ec1bd..000000000000 --- a/images/linux/scripts/installers/aws-sam-cli.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -e -################################################################################ -## File: aws-sam-cli.sh -## Desc: Installs AWS SAM CLI -## Requires Python >=3.6, must be run as non-root user after toolset installation -################################################################################ - -# Source the helpers for use with the script -source $HELPER_SCRIPTS/install.sh - -# Download latest aws sam cli sources -TarballUrl=$(curl -s https://api.github.com/repos/aws/aws-sam-cli/releases/latest | jq -r '.tarball_url') -TarballPath="/tmp/aws-sam-cli.tar.gz" -download_with_retries $TarballUrl "/tmp" "aws-sam-cli.tar.gz" -tar -xzf $TarballPath -C /tmp -cd /tmp/aws-aws-sam-cli* - -mkdir /opt/python-aws-sam-cli -cp -r /opt/hostedtoolcache/Python/3.7* /opt/python-aws-sam-cli - -# Use copy of python 3.7 from toolcache to install aws sam, setuptools package required for the installation -Python3Dir=$(echo /opt/python-aws-sam-cli/3.7*/x64) -Python3BinDir="${Python3Dir}/bin" -$Python3BinDir/python3 -m pip install setuptools -$Python3BinDir/python3 setup.py install -ln -sf ${Python3BinDir}/sam /usr/local/bin/sam - -invoke_tests "CLI.Tools" "AWS SAM CLI" diff --git a/images/linux/scripts/installers/aws.sh b/images/linux/scripts/installers/aws.sh index cba85d7f9371..5bfab832c02c 100644 --- a/images/linux/scripts/installers/aws.sh +++ b/images/linux/scripts/installers/aws.sh @@ -1,7 +1,7 @@ #!/bin/bash -e ################################################################################ ## File: aws.sh -## Desc: Installs the AWS CLI +## Desc: Installs the AWS CLI, Session Manager plugin for the AWS CLI, and AWS SAM CLI ################################################################################ # Source the helpers for use with the script @@ -24,4 +24,11 @@ fi download_with_retries "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_64bit/session-manager-plugin.deb" "/tmp" "session-manager-plugin.deb" apt install /tmp/session-manager-plugin.deb +# Download & install the latest aws sam cli release +zipName="aws-sam-cli-linux-x86_64.zip" +zipUrl="https://github.com/aws/aws-sam-cli/releases/latest/download/${zipName}" +download_with_retries $zipUrl "/tmp" $zipName +unzip /tmp/${zipName} -d /tmp +/tmp/install + invoke_tests "CLI.Tools" "AWS" diff --git a/images/linux/scripts/tests/CLI.Tools.Tests.ps1 b/images/linux/scripts/tests/CLI.Tools.Tests.ps1 index c7e43bb90fa5..ba21be6344a4 100644 --- a/images/linux/scripts/tests/CLI.Tools.Tests.ps1 +++ b/images/linux/scripts/tests/CLI.Tools.Tests.ps1 @@ -25,9 +25,7 @@ Describe "AWS" { It "Session Manager Plugin for the AWS CLI" { session-manager-plugin | Out-String | Should -Match "plugin was installed successfully" } -} -Describe "AWS SAM CLI" { It "AWS SAM CLI" { "sam --version" | Should -ReturnZeroExitCode } diff --git a/images/linux/toolsets/toolset-1804.json b/images/linux/toolsets/toolset-1804.json index 2b96ab0d9d40..0f45c6ac0af2 100644 --- a/images/linux/toolsets/toolset-1804.json +++ b/images/linux/toolsets/toolset-1804.json @@ -223,10 +223,6 @@ "package": "yamllint", "cmd": "yamllint" }, - { - "package": "aws-sam-cli", - "cmd": "sam" - }, { "package": "ansible-base", "cmd": "ansible" diff --git a/images/linux/toolsets/toolset-2004.json b/images/linux/toolsets/toolset-2004.json index 72a6873cfae4..fd6b1bf29057 100644 --- a/images/linux/toolsets/toolset-2004.json +++ b/images/linux/toolsets/toolset-2004.json @@ -223,10 +223,6 @@ "package": "yamllint", "cmd": "yamllint" }, - { - "package": "aws-sam-cli", - "cmd": "sam" - }, { "package": "ansible-base", "cmd": "ansible" diff --git a/images/linux/ubuntu1604.json b/images/linux/ubuntu1604.json index e64ebe9f700e..39579597b5bb 100644 --- a/images/linux/ubuntu1604.json +++ b/images/linux/ubuntu1604.json @@ -265,16 +265,6 @@ ], "execute_command": "sudo sh -c '{{ .Vars }} pwsh -f {{ .Path }}'" }, - { - "type": "shell", - "scripts": [ - "{{template_dir}}/scripts/installers/aws-sam-cli.sh" - ], - "environment_vars": [ - "HELPER_SCRIPTS={{user `helper_script_folder`}}" - ], - "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" - }, { "type": "shell", "scripts": [