diff --git a/.github/workflows/build_aws_minimal_manual.yml b/.github/workflows/build_aws_minimal_manual.yml deleted file mode 100644 index 80b02c0..0000000 --- a/.github/workflows/build_aws_minimal_manual.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: AWS minimal AMI manual publish - -on: - workflow_dispatch: - -jobs: - timestamp: - name: Get the build timestamp - runs-on: ubuntu-latest - outputs: - timestamp: ${{ steps.timestamp.outputs.timestamp }} - steps: - - name: Get the timestamp - id: timestamp - run: echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT - - build: - # Since we run in parallel, let's make sure we use the same timestamp for all jobs - needs: timestamp - strategy: - matrix: - arch: [x86_64, arm64] - name: Build the AWS AMI using Packer - runs-on: ubuntu-latest - permissions: - id-token: write - contents: read - steps: - - name: Check out the source code - uses: actions/checkout@main - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-region: ${{ secrets.AWS_REGION }} - role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - role-duration-seconds: 3600 - - - name: Setup packer - uses: hashicorp/setup-packer@main - with: - version: latest - - - name: Initialize Packer - run: packer init aws_minimal.pkr.hcl - - - name: Build the AWS AMI using Packer (${{ matrix.arch }}) - run: packer build aws_minimal.pkr.hcl - env: - PKR_VAR_encrypt_boot: false - PKR_VAR_ami_name_prefix: minimal-beta-spacelift-${{ needs.timestamp.outputs.timestamp }} - PKR_VAR_source_ami_architecture: ${{ matrix.arch }} - PKR_VAR_instance_type: ${{ matrix.arch == 'x86_64' && 't3.micro' || 't4g.micro' }} - - - name: Upload manifest - uses: actions/upload-artifact@v3 - with: - path: manifest_aws_minimal_${{ matrix.arch }}.json - name: manifest_aws_minimal_${{ matrix.arch }}.json - retention-days: 5 diff --git a/aws.pkr.hcl b/aws.pkr.hcl index 81d2608..eca1919 100644 --- a/aws.pkr.hcl +++ b/aws.pkr.hcl @@ -89,7 +89,7 @@ source "amazon-ebs" "spacelift" { source_ami_filter { filters = { virtualization-type = "hvm" - name = "amzn2-ami-kernel-5.10-hvm-2*-gp2" + name = "al2023-ami-minimal-*-kernel-6.1-${var.source_ami_architecture}" root-device-type = "ebs" architecture = var.source_ami_architecture } @@ -144,11 +144,12 @@ build { provisioner "shell" { scripts = [ "shared/scripts/data-directories.sh", - "aws/scripts/yum-update.sh", + "aws/scripts/dnf-update.sh", + "aws/scripts/system-deps.sh", "aws/scripts/docker.sh", "shared/scripts/gvisor.sh", "aws/scripts/cloudwatch-agent.sh", - "aws/scripts/jq.sh", + "aws/scripts/ssm-agent.sh" ] } diff --git a/aws/scripts/cloudwatch-agent.sh b/aws/scripts/cloudwatch-agent.sh index 5d9bc01..c7f38fc 100644 --- a/aws/scripts/cloudwatch-agent.sh +++ b/aws/scripts/cloudwatch-agent.sh @@ -11,7 +11,7 @@ fi DOWNLOAD_URL=https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/${CURRENTARCH}/latest/amazon-cloudwatch-agent.rpm RPM_PATH=/tmp/amazon-cloudwatch-agent.rpm -touch /var/log/spacelift/{info,error}.log +sudo touch /var/log/spacelift/{info,error}.log curl $DOWNLOAD_URL --output $RPM_PATH sudo rpm -U $RPM_PATH diff --git a/aws_minimal/scripts/dnf-update.sh b/aws/scripts/dnf-update.sh similarity index 100% rename from aws_minimal/scripts/dnf-update.sh rename to aws/scripts/dnf-update.sh diff --git a/aws/scripts/docker.sh b/aws/scripts/docker.sh index 620ba9f..8f2ce7d 100644 --- a/aws/scripts/docker.sh +++ b/aws/scripts/docker.sh @@ -1,5 +1,4 @@ # This script installs and starts Docker. -sudo amazon-linux-extras install docker -sudo systemctl enable docker -sudo service docker start +sudo dnf install -y docker +sudo systemctl enable --now docker diff --git a/aws/scripts/jq.sh b/aws/scripts/jq.sh deleted file mode 100644 index 59c8074..0000000 --- a/aws/scripts/jq.sh +++ /dev/null @@ -1,3 +0,0 @@ -# This script installs jq. - -sudo yum install -y jq diff --git a/aws_minimal/scripts/ssm-agent.sh b/aws/scripts/ssm-agent.sh similarity index 100% rename from aws_minimal/scripts/ssm-agent.sh rename to aws/scripts/ssm-agent.sh diff --git a/aws_minimal/scripts/system-deps.sh b/aws/scripts/system-deps.sh similarity index 100% rename from aws_minimal/scripts/system-deps.sh rename to aws/scripts/system-deps.sh diff --git a/aws/scripts/yum-update.sh b/aws/scripts/yum-update.sh deleted file mode 100644 index 06fe307..0000000 --- a/aws/scripts/yum-update.sh +++ /dev/null @@ -1,3 +0,0 @@ -# This script updates the installed packages and package cache on the instance. - -sudo yum update -y diff --git a/aws_minimal.pkr.hcl b/aws_minimal.pkr.hcl deleted file mode 100644 index 5a01db7..0000000 --- a/aws_minimal.pkr.hcl +++ /dev/null @@ -1,152 +0,0 @@ -packer { - required_plugins { - amazon-ami-management = { - version = "2.0.0" - source = "github.com/spacelift-io/amazon-ami-management" - } - } -} - -variable "ami_name_prefix" { - type = string - default = "minimal-spacelift-{{timestamp}}" -} - -variable "ami_regions" { - type = list(string) - default = [ - "eu-west-1" - ] -} - -variable "source_ami_architecture" { - type = string - default = "x86_64" -} - -variable "source_ami_owners" { - type = list(string) - default = ["137112412989"] # defaults to Amazon for Amazon Linux, see https://docs.aws.amazon.com/AmazonECR/latest/userguide/amazon_linux_container_image.html -} - -variable "ami_groups" { - type = list(string) - default = ["all"] -} - -variable "instance_type" { - type = string - default = "t3.micro" -} - -variable "encrypt_boot" { - type = bool - default = true -} - -variable "shared_credentials_file" { - type = string - default = null -} - -variable "subnet_filter" { - type = map(string) - default = null -} - -variable "additional_tags" { - type = map(string) - default = {} -} - -variable "region" { - type = string - default = "eu-west-1" -} - -variable "vpc_id" { - type = string - default = null -} - -source "amazon-ebs" "spacelift" { - source_ami_filter { - filters = { - virtualization-type = "hvm" - name = "al2023-ami-minimal-*-kernel-6.1-${var.source_ami_architecture}" - root-device-type = "ebs" - architecture = var.source_ami_architecture - } - owners = var.source_ami_owners - most_recent = true - } - - ami_name = "${var.ami_name_prefix}-${var.source_ami_architecture}" - ami_regions = var.ami_regions - ami_groups = var.ami_groups - ami_description = <