Skip to content

Commit

Permalink
chore: add update environment beanstalk in action
Browse files Browse the repository at this point in the history
  • Loading branch information
Matheusafonsouza committed Nov 2, 2022
1 parent c5ef042 commit 50f087e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/deploy-prd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,10 @@ jobs:
IMAGE_TAG: ${{ needs.gen-tag.outputs.tag }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./application
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: Update beanstalk version
env:
ENVIRONMENT: production
run: |
aws elasticbeanstalk update-environment --environment-name $ENVIRONMENT --version-label $ENVIRONMENT
14 changes: 14 additions & 0 deletions beanstalk.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,17 @@ resource "aws_elastic_beanstalk_environment" "environment" {
value = aws_iam_instance_profile.beanstalk_ec2_profile.name
}
}

resource "aws_elastic_beanstalk_application_version" "version" {
depends_on = [
aws_elastic_beanstalk_environment.environment,
aws_elastic_beanstalk_application.application,
aws_s3_bucket_object.beanstalk_docker
]

name = var.environment
application = var.application_name
description = var.application_description
bucket = aws_s3_bucket.beanstalk_deploys.id
key = aws_s3_bucket_object.beanstalk_docker.id
}
7 changes: 4 additions & 3 deletions env/prod/Dockerrun.aws.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "384775792797.dkr.ecr.us-east-1.amazonaws.com/docker-beanstalk-production"
"Name": "384775792797.dkr.ecr.us-east-1.amazonaws.com/docker-beanstalk-production",
"Update": true
},
"Ports": [
{
"ContainerPort": "8000",
"HostPort": "8000"
"ContainerPort": "8000"
}
]
}
Binary file added env/prod/docker-beanstalk-production.zip
Binary file not shown.
14 changes: 14 additions & 0 deletions s3.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
resource "aws_s3_bucket" "beanstalk_deploys" {
bucket = "${var.repository_name}-deploys"
force_destroy = true
}

resource "aws_s3_bucket_object" "beanstalk_docker" {
depends_on = [
aws_s3_bucket.beanstalk_deploys
]
bucket = "${var.repository_name}-deploys"
key = "${var.repository_name}.zip"
source = "${var.repository_name}.zip"
etag = filemd5("${var.repository_name}.zip")
}

0 comments on commit 50f087e

Please sign in to comment.