-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updated tf files * updating tf code (#1) * Create deploy.yml * Updating deploy.yml * Updated deploy.yml --------- Co-authored-by: damienmwene <[email protected]> Co-authored-by: damienmwene <[email protected]>
- Loading branch information
1 parent
fc65fa4
commit 9fb5992
Showing
6 changed files
with
76 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Deploy to EC2 using AWS CLI | ||
|
||
on: | ||
push: | ||
branches: | ||
- Dev | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v3 | ||
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: Install AWS CLI | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y awscli | ||
- name: Deploy to EC2 via SSM | ||
run: | | ||
aws ssm send-command \ | ||
--instance-ids "i-004aee8ed40389322" \ | ||
--document-name "AWS-RunShellScript" \ | ||
--comment "GitHub Actions EC2 deployment" \ | ||
--parameters commands='cd /var/www/html && git pull origin Dev && sudo systemctl restart httpd' \ | ||
--output text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
terraform.tfstate | ||
terraform.tfstate.backup | ||
.terraform | ||
.terraform.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "5.72.0" | ||
} | ||
} | ||
} | ||
|
||
provider "aws" { | ||
region = "us-east-1" | ||
profile = "wp-migration" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
yum update -y | ||
yum install -y httpd mysql php php-mysql | ||
systemctl start httpd | ||
systemctl enable httpd | ||
cd /var/www/html | ||
wget https://wordpress.org/latest.tar.gz | ||
tar -xzf latest.tar.gz | ||
mv wordpress/* . | ||
chown -R apache:apache /var/www/html | ||
systemctl restart httpd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
variable "ami" { | ||
description = "The AMI ID for the EC2 instance" | ||
type = string | ||
default = "ami-00f251754ac5da7f0" | ||
default = "ami-00f251754ac5da7f0" | ||
|
||
|
||
} | ||
|
||
variable "instance_type" { | ||
description = "The EC2 instance type" | ||
type = string | ||
default = "t2.micro" | ||
default = "t2.micro" | ||
} | ||
|
||
variable "availability_zone" { | ||
description = "The availability zone for the subnet" | ||
type = string | ||
default = "us-east-1" | ||
default = "us-east-1a" | ||
|
||
} |