Skip to content

Commit

Permalink
Add initial workflow, format hcl2 files
Browse files Browse the repository at this point in the history
  • Loading branch information
shub-kris committed Jan 25, 2024
1 parent 044bb6d commit c476536
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 12 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/build-ami.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build AWS Neuron AMI

on:
push:
branches:
- main
paths:
- 'aws-ami-creation/**'
workflow_dispatch:
schedule:
# Schedule the workflow to run every second day at midnight UTC
- cron: '0 0 */2 * *'

jobs:
build-ami:
defaults:
run:
working-directory: aws-ami-creation
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v3
- uses: hashicorp/setup-packer@main

- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Packer format
id: format
run: packer fmt hcl2-files
continue-on-error: true

- name: Packer Init
id: init
run: packer init hcl2-files
continue-on-error: true

- name: Packer Validate
id: validate
run: packer validate hcl2
continue-on-error: true

- name: Packer Build
id: build
run: packer build hcl2

5 changes: 0 additions & 5 deletions aws-ami-creation/hcl2-files/build.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ build {
sources = [
"source.amazon-ebs.ubuntu"
]
// provisioner "shell" {
// inline = [
// "echo foo"
// ]
// }
provisioner "shell" {
script = "scripts/validate_neuron_exist.sh"
}
Expand Down
2 changes: 1 addition & 1 deletion aws-ami-creation/hcl2-files/packer.pkr.hcl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
packer {
required_plugins {
docker = {
amazon = {
version = ">= 1.2.8"
source = "github.com/hashicorp/amazon"
}
Expand Down
10 changes: 5 additions & 5 deletions aws-ami-creation/hcl2-files/sources.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ source "amazon-ebs" "ubuntu" {
source_ami = var.source_ami
ssh_username = var.ssh_username
launch_block_device_mappings {
device_name = "/dev/sda1"
encrypted = true
volume_size = 100
volume_type = "gp2"
delete_on_termination = true
device_name = "/dev/sda1"
encrypted = true
volume_size = 100
volume_type = "gp2"
delete_on_termination = true
}
}
2 changes: 1 addition & 1 deletion aws-ami-creation/hcl2-files/variables.pkr.hcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
variable "region" {
default = "us-west-2"
default = "us-east-1"
description = "The AWS region you're using"
type = string
}
Expand Down

0 comments on commit c476536

Please sign in to comment.