Skip to content

Commit 62971e3

Browse files
Fixed the ami id and try to set the apply changes to a manual step (#14)
* Fixed the ami id and try to set the apply changes to a manual step * Fixed the github workflow actions upload/download * Added apply changes to manual workflow for production
1 parent c05fd0b commit 62971e3

8 files changed

Lines changed: 114 additions & 80 deletions

.github/workflows/continuos_deployment_production.yml

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -71,29 +71,12 @@ jobs:
7171
unset AWS_PROFILE
7272
terraform plan -out planfile
7373
74-
# ---------------------
75-
- name: Terraform apply
76-
run: |
77-
cd terraform
78-
cat .envrc | grep -vE '^(dotenv_if_exists|source_env)' > .envrc.good
79-
. ./.envrc.good
80-
cd ${{ env.ENVIRONMENT }}
81-
cat .envrc | grep -vE '^(dotenv_if_exists|source_env)' > .envrc.good
82-
. ./.envrc.good
83-
unset AWS_PROFILE
84-
terraform apply -input=false planfile
85-
86-
# --------------------------------------------------------------------------------------
87-
# - name: Post Deploy - Test Service for Server has Correct Task Definition Deployed
88-
# run: |
89-
# cd terraform
90-
# cat .envrc | grep -vE '^(dotenv_if_exists|source_env)' > .envrc.good
91-
# . ./.envrc.good
92-
# cd ${{ env.ENVIRONMENT }}
93-
# cat .envrc | grep -vE '^(dotenv_if_exists|source_env)' > .envrc.good
94-
# . ./.envrc.good
95-
# unset AWS_PROFILE
96-
# export ECS_CLUSTER_NAME_SERVER=$(terraform output -raw error_logs_server_cluster_name)
97-
# export ECS_SERVICE_NAME_SERVER=$(terraform output -raw error_logs_server_service_name)
98-
# export ECS_TASK_DEFINITION_SERVER=$(terraform output -raw error_logs_server_task_definition_revision)
99-
# ../test_deployed_task_definitions.sh "${AWS_REGION}" "${ECS_CLUSTER_NAME_SERVER}" "${ECS_SERVICE_NAME_SERVER}" "${ECS_TASK_DEFINITION_SERVER}"
74+
# Upload the plan as an artifact
75+
- name: Upload Terraform plan
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: terraform-${{ env.ENVIRONMENT }}-plan
79+
path: terraform/${{ env.ENVIRONMENT }}/planfile
80+
if-no-files-found: 'warn'
81+
retention-days: 1
82+
overwrite: true
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Continuos Deployment Action Production Apply Changes
2+
3+
on:
4+
workflow_dispatch:
5+
6+
env:
7+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_PLAY_DEVOPS }}
8+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_PLAY_DEVOPS }}
9+
10+
defaults:
11+
run:
12+
shell: bash
13+
14+
jobs:
15+
terraform_apply:
16+
runs-on: ubuntu-latest
17+
environment: production
18+
19+
env:
20+
ETHEREUM_PEM: ${{ secrets.ETHEREUM_PEM }}
21+
ENVIRONMENT: production
22+
GF_SECURITY_ADMIN_USER: "${{ secrets.GF_SECURITY_ADMIN_USER }}"
23+
GF_SECURITY_ADMIN_PASSWORD: "${{ secrets.GF_SECURITY_ADMIN_PASSWORD }}"
24+
PROMETHEUS_ADMIN_PASSWORD: "${{ secrets.PROMETHEUS_ADMIN_PASSWORD }}"
25+
PROMETHEUS_ADMIN_PASSWORD_BCRYPTED: "${{ secrets.PROMETHEUS_ADMIN_PASSWORD_BCRYPTED }}"
26+
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v3
30+
31+
- name: Download Terraform plan
32+
uses: actions/download-artifact@v4
33+
with:
34+
name: terraform-${{ env.ENVIRONMENT }}-plan
35+
path: terraform/${{ env.ENVIRONMENT }}
36+
37+
- name: Terraform apply
38+
run: |
39+
cd terraform
40+
cat .envrc | grep -vE '^(dotenv_if_exists|source_env)' > .envrc.good
41+
. ./.envrc.good
42+
cd ${{ env.ENVIRONMENT }}
43+
cat .envrc | grep -vE '^(dotenv_if_exists|source_env)' > .envrc.good
44+
. ./.envrc.good
45+
unset AWS_PROFILE
46+
terraform apply -input=false planfile

.github/workflows/continuos_deployment_staging.yml

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -71,29 +71,12 @@ jobs:
7171
unset AWS_PROFILE
7272
terraform plan -out planfile
7373
74-
# ---------------------
75-
- name: Terraform apply
76-
run: |
77-
cd terraform
78-
cat .envrc | grep -vE '^(dotenv_if_exists|source_env)' > .envrc.good
79-
. ./.envrc.good
80-
cd ${{ env.ENVIRONMENT }}
81-
cat .envrc | grep -vE '^(dotenv_if_exists|source_env)' > .envrc.good
82-
. ./.envrc.good
83-
unset AWS_PROFILE
84-
terraform apply -input=false planfile
85-
86-
# --------------------------------------------------------------------------------------
87-
# - name: Post Deploy - Test Service for Server has Correct Task Definition Deployed
88-
# run: |
89-
# cd terraform
90-
# cat .envrc | grep -vE '^(dotenv_if_exists|source_env)' > .envrc.good
91-
# . ./.envrc.good
92-
# cd ${{ env.ENVIRONMENT }}
93-
# cat .envrc | grep -vE '^(dotenv_if_exists|source_env)' > .envrc.good
94-
# . ./.envrc.good
95-
# unset AWS_PROFILE
96-
# export ECS_CLUSTER_NAME_SERVER=$(terraform output -raw error_logs_server_cluster_name)
97-
# export ECS_SERVICE_NAME_SERVER=$(terraform output -raw error_logs_server_service_name)
98-
# export ECS_TASK_DEFINITION_SERVER=$(terraform output -raw error_logs_server_task_definition_revision)
99-
# ../test_deployed_task_definitions.sh "${AWS_REGION}" "${ECS_CLUSTER_NAME_SERVER}" "${ECS_SERVICE_NAME_SERVER}" "${ECS_TASK_DEFINITION_SERVER}"
74+
# Upload the plan as an artifact
75+
- name: Upload Terraform plan
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: terraform-${{ env.ENVIRONMENT }}-plan
79+
path: terraform/${{ env.ENVIRONMENT }}/planfile
80+
if-no-files-found: 'warn'
81+
retention-days: 1
82+
overwrite: true
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Continuos Deployment Action Staging Apply Changes
2+
3+
on:
4+
workflow_dispatch:
5+
6+
env:
7+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_PLAY_DEVOPS }}
8+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_PLAY_DEVOPS }}
9+
10+
defaults:
11+
run:
12+
shell: bash
13+
14+
jobs:
15+
terraform_apply:
16+
runs-on: ubuntu-latest
17+
environment: staging
18+
19+
env:
20+
ETHEREUM_PEM: ${{ secrets.ETHEREUM_PEM }}
21+
ENVIRONMENT: staging
22+
GF_SECURITY_ADMIN_USER: "${{ secrets.GF_SECURITY_ADMIN_USER }}"
23+
GF_SECURITY_ADMIN_PASSWORD: "${{ secrets.GF_SECURITY_ADMIN_PASSWORD }}"
24+
PROMETHEUS_ADMIN_PASSWORD: "${{ secrets.PROMETHEUS_ADMIN_PASSWORD }}"
25+
PROMETHEUS_ADMIN_PASSWORD_BCRYPTED: "${{ secrets.PROMETHEUS_ADMIN_PASSWORD_BCRYPTED }}"
26+
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v3
30+
31+
- name: Download Terraform plan
32+
uses: actions/download-artifact@v4
33+
with:
34+
name: terraform-${{ env.ENVIRONMENT }}-plan
35+
path: terraform/${{ env.ENVIRONMENT }}
36+
37+
- name: Terraform apply
38+
run: |
39+
cd terraform
40+
cat .envrc | grep -vE '^(dotenv_if_exists|source_env)' > .envrc.good
41+
. ./.envrc.good
42+
cd ${{ env.ENVIRONMENT }}
43+
cat .envrc | grep -vE '^(dotenv_if_exists|source_env)' > .envrc.good
44+
. ./.envrc.good
45+
unset AWS_PROFILE
46+
terraform apply -input=false planfile

terraform/ethereum_ec2_instance.tf

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,5 @@
1-
data "aws_ami" "ubuntu" {
2-
most_recent = true
3-
4-
filter {
5-
name = "block-device-mapping.delete-on-termination"
6-
values = ["true"]
7-
}
8-
9-
filter {
10-
name = "is-public"
11-
values = ["true"]
12-
}
13-
14-
15-
filter {
16-
name = "name"
17-
values = ["ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-arm64-server*"]
18-
}
19-
20-
filter {
21-
name = "root-device-type"
22-
values = ["ebs"]
23-
}
24-
25-
owners = ["099720109477"] # Canonical
26-
}
27-
281
resource "aws_instance" "ethereum" {
29-
ami = data.aws_ami.ubuntu.id
2+
ami = var.ethereum_node.ami_id
303
associate_public_ip_address = var.ethereum_node.associate_public_ip_address
314
availability_zone = "${var.region}${var.ethereum_node.availability_zone}"
325
ebs_optimized = var.ethereum_node.ebs_optimized

terraform/production/terraform.tfvars

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
ethereum_node = {
22
alarm_memory_threshold_percentage = 80
33
alarm_disk_used_threshold_percentage = 90
4+
ami_id = "ami-0122205e4fe2524d5" # ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-arm64-server-20250821
45
associate_public_ip_address = true
56
availability_zone = "a"
67
chain = "mainnet"

terraform/staging/terraform.tfvars

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
ethereum_node = {
22
alarm_memory_threshold_percentage = 80
33
alarm_disk_used_threshold_percentage = 90
4+
ami_id = "ami-0122205e4fe2524d5" # ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-arm64-server-20250821
45
associate_public_ip_address = true
56
availability_zone = "a"
67
chain = "sepolia"

terraform/variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ variable "ethereum_node" {
3535
type = object({
3636
alarm_memory_threshold_percentage = number
3737
alarm_disk_used_threshold_percentage = number
38+
ami_id = string
3839
associate_public_ip_address = bool
3940
availability_zone = string
4041
chain = string

0 commit comments

Comments
 (0)