Skip to content
This repository has been archived by the owner on Mar 9, 2024. It is now read-only.

launched AMI and Created Snapshot of the AMI #8

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
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: 2 additions & 2 deletions Ansible/vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ server_name: dev2.snipeit.com

#REPO

repo: https://github.com/PearlThoughts-Platform/Snipe-IT-GitHub-Actions
repo: https://github.com/kesarivamshi/Snipe-IT-GitHub-Actions.git
repo_branch: devcontainer
api_project_dir: /srv/Snipe-IT-GitHub-Actions
api1_secret_name: smw ## store the .env values in AWS secret manager as a json key pair values and mention the secret name.
Expand Down Expand Up @@ -52,4 +52,4 @@ php_extensions:


host_user: ubuntu
group_name: deploy
group_name: deploy
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Every commit will automatically creates AMI
```
### Terraform for Infra provisioning
terraform folder

....

### Demo Video For Reference

Expand Down
10 changes: 5 additions & 5 deletions ami.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ packer {

source "amazon-ebs" "linux" {
# AMI Settings
ami_name = "snipeitdev_goldenAMI_${var.build_number}"
instance_type = "c5.large"
source_ami = "ami-00978328f54e31526"
ami_name = "snipeit_goldenAMI_${var.build_number}"
instance_type = "t2.micro"
source_ami = "ami-08c40ec9ead489470"
ssh_username = "ubuntu"
associate_public_ip_address = false
ami_virtualization_type = "hvm"
Expand Down Expand Up @@ -48,7 +48,7 @@ packer {
}

# Profile Settings
region = "us-east-2"
region = "us-east-1"
ami_regions = ["us-east-1"]
}

Expand All @@ -60,4 +60,4 @@ packer {
playbook_file = "Ansible/main.yml"
user = "ubuntu"
}
}
}
122 changes: 58 additions & 64 deletions terraform/.github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,58 @@
# name: "Terraform Deployment"
# on:
# # Manual trigger
# workflow_dispatch:
# push:
# paths:
# - '*/**'
# pull_request:
# branches: [ main ]
# defaults:
# run:
# shell: bash
# jobs:
# terraform:
# name: ${{matrix.runner}} - ${{ matrix.environment }}
# runs-on: [ '${{ matrix.runner }}']
# strategy:
# max-parallel: 1
# matrix:
# include:
# - environment: test
# runner: ubuntu-latest
# - environment: prod
# runner: ubuntu-18.04
# env:
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# AWS_DEFAULT_REGION: us-east-2
# steps:
# - uses: actions/checkout@v2
# - uses: hashicorp/setup-terraform@v1
# with:
# terraform_wrapper: false
# - name: Terraform Init
# id: init
# run: |
# rm -rf .terraform
# terraform init -upgrade=true -no-color -input=false
# - name: Terraform Plan
# id: plan
# run: |
# terraform plan -input=false -no-color
# - name: Terraform Apply
# if: github.ref == 'refs/heads/main'
# id: apply
# run: terraform apply -auto-approve -input=false
# - name: Terraform destroy
# if: github.ref == 'refs/heads/destroy'
# id: destroy
# run: terraform destroy -auto-approve -input=false
# comment:
# runs-on: ubuntu-latest
# needs: terraform
# if: github.event_name == 'pull_request'
# steps:
# - uses: actions/github-script@v5
# with:
# script: |
# github.rest.issues.createComment({
# issue_number: context.issue.number,
# owner: context.repo.owner,
# repo: context.repo.repo,
# body: '👋 Thanks for reporting!'
# })
name: "Terraform Deployment"
on:
push:
branches:
- main
pull_request:
jobs:
terraform:
name: ${{matrix.runner}} - ${{ matrix.environment }}
runs-on: [ '${{ matrix.runner }}']
strategy:
max-parallel: 1
matrix:
include:
- environment: test
runner: ubuntu-latest
- environment: prod
runner: ubuntu-18.04
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
steps:
- uses: actions/checkout@v2
- uses: hashicorp/setup-terraform@v1
with:
terraform_wrapper: false
- name: Terraform Init
id: init
run: |
rm -rf .terraform
terraform init -upgrade=true -no-color -input=false
- name: Terraform Plan
id: plan
run: |
terraform plan -input=false -no-color
- name: Terraform Apply
if: github.ref == 'refs/heads/main'
id: apply
run: terraform apply -auto-approve -input=false
- name: Terraform destroy
if: github.ref == 'refs/heads/destroy'
id: destroy
run: terraform destroy -auto-approve -input=false
comment:
runs-on: ubuntu-latest
needs: terraform
if: github.event_name == 'pull_request'
steps:
- uses: actions/github-script@v5
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '👋 Thanks for reporting!'
})
4 changes: 2 additions & 2 deletions terraform/provider.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
provider "aws" {
region = "us-east-1"
access_key = "AKIAQWYSZRJYQM5d4"
secret_key = "adeZNE1Id82orq/yt9VI36R7/iBS5JPwmabddd"
access_key = "AKIAR6HMURYL22YOQJ4L"
secret_key = "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"
}


Expand Down