File tree Expand file tree Collapse file tree 6 files changed +184
-0
lines changed
Expand file tree Collapse file tree 6 files changed +184
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Digger Plan
2+
3+ on :
4+ pull_request :
5+ branches : [ "main" ]
6+ types : [ opened, synchronize ]
7+ issue_comment :
8+ types : [created]
9+ workflow_dispatch :
10+
11+
12+ jobs :
13+ plan :
14+ runs-on : ubuntu-latest
15+ permissions :
16+ contents : write # required to merge PRs
17+ id-token : write # required for workload-identity-federation
18+ pull-requests : write # required to post PR comments
19+ statuses : write # required to validate combined PR status
20+
21+ steps :
22+ - uses : actions/checkout@v4
23+ # Unlike GCP; the role assumption is handled inline
24+ - name : digger run
25+ uses : diggerhq/digger@v0.2.0
26+ with :
27+ setup-aws : true
28+
29+ # Uncomment below line if using OIDC
30+ # aws-role-to-assume: arn:aws:sts::{secrets.AccountID}:assumed-role/{secrets.RoleName}/{FunctionName}
31+
32+ # Comment the following two lines out if using OIDC.
33+ aws-access-key-id : ${{ secrets.AWS_ACCESS_KEY_ID }}
34+ aws-secret-access-key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
35+ # #End comment block
36+ aws-region : us-east-1
37+ env :
38+ GITHUB_CONTEXT : ${{ toJson(github) }}
39+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
40+
Original file line number Diff line number Diff line change 1+ gcp_key.json
2+
3+ # Local .terraform directories
4+ ** /.terraform /*
5+ .terraform
6+ # .tfstate files
7+ * .tfstate
8+ * .tfstate. *
9+
10+ # Crash log files
11+ crash.log
12+ crash. * .log
13+
14+ # Exclude all .tfvars files, which are likely to contain sensitive data, such as
15+ # password, private keys, and other secrets. These should not be part of version
16+ # control as they are data points which are potentially sensitive and subject
17+ # to change depending on the environment.
18+ * .tfvars
19+ * .tfvars.json
20+
21+ # Ignore override files as they are usually used to override resources locally and so
22+ # are not checked in
23+ override.tf
24+ override.tf.json
25+ * _override.tf
26+ * _override.tf.json
27+
28+ .terraform.lock.hcl
Original file line number Diff line number Diff line change 11# quickstart-actions-aws
2+
3+ This is the repository for a sample quickstart action with digger.
4+
5+ # backend
6+ this folder will provision (most) of the backend required.
7+ Main.tf provisions the following resources.
8+
9+ 1 . The Backend state bucket for terraform to store state in
10+ 2 . The required DynamoDB table for Digger to store locks.
11+
12+ # prod
13+ This is a sample terraform prod code that will (if given the chance) spin up a vpc + an EC2 instance, and required security groups.
14+ The instance is locked down to not be accessible from outside the network.
15+
16+ # .github/workflows
17+ Contains digger-plan.yml with two different potential ways of authenticating against an AWS account. Please review the main digger documentation on details as to which scheme to use.
Original file line number Diff line number Diff line change 1+ terraform {
2+ required_providers {
3+ aws = {
4+ source = " hashicorp/aws"
5+ version = " 5.23.1"
6+ }
7+ }
8+ }
9+
10+ provider "aws" {
11+ region = " us-east-1" # Replace with your desired AWS region
12+ }
13+
14+ resource "random_string" "bucket_prefix" {
15+ length = 8
16+ special = false
17+ }
18+
19+ resource "aws_s3_bucket" "default" {
20+ bucket = " ${ random_string . bucket_prefix . result } -bucket-tfstate"
21+ }
22+
23+ resource "aws_s3_bucket_versioning" "versioning_example" {
24+ bucket = aws_s3_bucket. default . id
25+ versioning_configuration {
26+ status = " Enabled"
27+ }
28+ }
29+
30+ resource "aws_s3_bucket_acl" "example" {
31+ bucket = aws_s3_bucket. default . id
32+ acl = " private"
33+ }
34+
35+
36+ resource "aws_dynamodb_table" "DiggerDynamoDBLockTable" {
37+ name = " DiggerDynamoDBLockTable"
38+ billing_mode = " PAY_PER_REQUEST"
39+ stream_enabled = true
40+ stream_view_type = " NEW_AND_OLD_IMAGES"
41+ }
Original file line number Diff line number Diff line change 1+ projects :
2+ - name : production
3+ dir : prod
Original file line number Diff line number Diff line change 1+ terraform {
2+ required_providers {
3+ aws = {
4+ source = " hashicorp/aws"
5+ version = " 3.0.0" # Use an appropriate version
6+ }
7+ }
8+ backend "s3" {
9+ bucket = " 8046b8f4c208f5bb-bucket-tfstate"
10+ key = " terraform/state"
11+ region = " us-east-1"
12+ }
13+
14+ }
15+
16+ provider "aws" {
17+ region = " us-east-1" # Replace with your desired AWS region
18+ }
19+
20+ resource "aws_vpc" "vpc_network" {
21+ cidr_block = " 10.0.0.0/16"
22+ tags = {
23+ Name = " terraform-network"
24+ }
25+ }
26+
27+ resource "aws_subnet" "vpc_subnet" {
28+ vpc_id = aws_vpc. vpc_network . id
29+ cidr_block = " 10.0.1.0/24"
30+ availability_zone = " us-east-2a"
31+ map_public_ip_on_launch = true
32+
33+ tags = {
34+ Name = " terraform-subnet"
35+ }
36+ }
37+
38+ resource "aws_security_group" "security_group" {
39+ name_prefix = " terraform-"
40+ ingress {
41+ from_port = 80
42+ to_port = 80
43+ protocol = " tcp"
44+ cidr_blocks = [" 0.0.0.0/0" ]
45+ }
46+ }
47+
48+ resource "aws_instance" "vm_instance" {
49+ ami = " ami-0b17ac7207aae009f" # Debian 11 (bullsey AMI provided by the Debian Project https://wiki.debian.org/Cloud/AmazonEC2Image/Bullseye)
50+ instance_type = " t2.micro"
51+ subnet_id = aws_subnet. vpc_subnet . id
52+ security_groups = [aws_security_group . security_group . name ]
53+ tags = {
54+ Name = " terraform-instance"
55+ }
56+ }
You can’t perform that action at this time.
0 commit comments