File tree Expand file tree Collapse file tree 5 files changed +147
-0
lines changed
Expand file tree Collapse file tree 5 files changed +147
-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+ aws-role-to-assume : arn:aws:sts::${{ secrets.AccountID }}:assumed-role/${{secrets.RoleName}}/${{FunctionName}}
29+ aws-region : us-east-1
30+ env :
31+ GITHUB_CONTEXT : ${{ toJson(github) }}
32+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
33+ LOCK_PROVIDER : aws
34+ AWS_STORAGE_BUCKET : ' digger-lock-prod'
35+
Original file line number Diff line number Diff line change 1+ gcp_key.json
2+
3+ # Local .terraform directories
4+ ** /.terraform /*
5+
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 1+ terraform {
2+ required_providers {
3+ aws = {
4+ source = " hashicorp/aws"
5+ version = " 3.0.0" # Use an appropriate version
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+ acl = " private" # You can adjust the ACL as needed
22+ versioning {
23+ enabled = true
24+ }
25+ }
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