-
Notifications
You must be signed in to change notification settings - Fork 1
Arihant/assignment-3-Automating-Deployment #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
notprowler
wants to merge
11
commits into
main
Choose a base branch
from
Arihant/assignment-3-Automating-Deployment
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e948f52
added terraform files
notprowler 18957bd
working terraform configurations
notprowler 47a82b7
terraform infra workflow
notprowler b687c42
fixup: terraform fmt
db52f4e
deployment files
notprowler 1a2d613
Merge branch 'Arihant/assignment-3-Automating-Deployment' of https://…
notprowler 3a76445
Update deploy_aws.yml
notprowler acfede2
Update deploy_aws.yml
notprowler a27b615
Update deploy_aws.yml
notprowler a0a76eb
Update terraform.yml
notprowler 581eab2
AWS charged me $10, commenting out for safety
notprowler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,51 @@ | ||
| # name: deploy-fastapi | ||
|
|
||
| # on: | ||
| # pull_request: | ||
| # branches: | ||
| # - main | ||
|
|
||
| # jobs: | ||
| # deploy: | ||
| # runs-on: ubuntu-latest | ||
| # steps: | ||
| # - name: Checkout code | ||
| # uses: actions/checkout@v4 | ||
|
|
||
| # - name: Set up Python | ||
| # uses: actions/setup-python@v4 | ||
| # with: | ||
| # python-version: 3.11 | ||
|
|
||
| # - name: Install dependencies | ||
| # run: | | ||
| # pip install -r backend/requirements.txt | ||
|
|
||
| # - name: Zip application | ||
| # run: | | ||
| # zip -r fastapi_deploy_${{ github.sha }}.zip backend -x "*/__pycache__/*" "*.pyc" | ||
|
|
||
| # - name: Configure AWS credentials | ||
| # uses: aws-actions/configure-aws-credentials@v2 | ||
| # with: | ||
| # aws-access-key-id: ${{ secrets.ACCESS_KEY_ID }} | ||
| # aws-secret-access-key: ${{ secrets.SECRET_ACCESS_KEY }} | ||
| # aws-region: us-east-1 | ||
|
|
||
| # - name: Upload to S3 | ||
| # run: | | ||
| # aws s3 cp fastapi_deploy_${{ github.sha }}.zip s3://terraform-state-chefit-notprowler/fastapi/fastapi_deploy_${{ github.sha }}.zip | ||
|
|
||
| # - name: Create new application version | ||
| # run: | | ||
| # aws elasticbeanstalk create-application-version \ | ||
| # --application-name chefit-backend \ | ||
| # --source-bundle S3Bucket="terraform-state-chefit-notprowler",S3Key=fastapi/fastapi_deploy_${{ github.sha }}.zip \ | ||
| # --version-label "ver-${{ github.sha }}" \ | ||
| # --description "FastAPI deploy at commit ${{ github.sha }}" | ||
|
|
||
| # - name: Deploy to environment | ||
| # run: | | ||
| # aws elasticbeanstalk update-environment \ | ||
| # --environment-name fastapi-env \ | ||
| # --version-label "ver-${{ github.sha }}" |
This file contains hidden or 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,88 @@ | ||
| # # This workflow will provision the infrastructure necessary to deploy. | ||
|
|
||
| # name: terraform | ||
|
|
||
| # on: | ||
| # push: | ||
| # branches: [ main ] | ||
| # paths: | ||
| # - 'terraform/*' | ||
| # - '.github/workflows/terraform.yml' | ||
| # pull_request: | ||
| # branches: [ main ] | ||
| # paths: | ||
| # - 'terraform/*' | ||
| # - '.github/workflows/terraform.yml' | ||
| # jobs: | ||
| # format: | ||
| # permissions: | ||
| # contents: write | ||
| # runs-on: ubuntu-latest | ||
|
|
||
| # name: Format | ||
|
|
||
| # steps: | ||
| # # Clone the repository. | ||
| # - uses: actions/checkout@v4 | ||
| # with: | ||
| # # This is required or we end up in detached head state & thus cannot push any changes. | ||
| # ref: ${{ github.head_ref }} | ||
| # # Download & set up the terraform CLI. | ||
| # - name: Set up terraform CLI | ||
| # uses: hashicorp/setup-terraform@v3 | ||
|
|
||
| # - run: terraform fmt -check | ||
| # working-directory: ./terraform | ||
| # id: fmt | ||
| # continue-on-error: ${{ github.event_name == 'pull_request' }} | ||
|
|
||
| # - name: update pr | ||
| # if: ${{ steps.fmt.outcome == 'failure' && github.event_name == 'pull_request' }} | ||
| # run: | | ||
| # terraform fmt | ||
| # git config --global user.name "terraform-fmt" | ||
| # git config --global user.email "noreply@corise.com" | ||
| # git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY | ||
| # git commit -am "fixup: terraform fmt" | ||
| # git push | ||
| # working-directory: ./terraform | ||
| # terraform: | ||
|
|
||
| # runs-on: ubuntu-latest | ||
|
|
||
| # name: Validate, Plan, and Apply | ||
| # env: | ||
| # AWS_ACCESS_KEY_ID: ${{ secrets.TERRAFORM_AWS_ACCESS_KEY_ID }} | ||
| # AWS_SECRET_ACCESS_KEY: ${{ secrets.TERRAFORM_AWS_SECRET_ACCESS_KEY }} | ||
|
|
||
| # steps: | ||
| # - uses: actions/checkout@v4 | ||
| # # Download & set up the terraform CLI. | ||
| # - name: Set up terraform CLI | ||
| # uses: hashicorp/setup-terraform@v3 | ||
| # # Initialize terraform. | ||
| # - name: terraform init | ||
| # working-directory: ./terraform | ||
| # id: init | ||
| # run: terraform init -input=false | ||
| # - name: terraform validate | ||
| # working-directory: ./terraform | ||
| # if: ${{ github.event_name == 'pull_request' }} | ||
| # run: terraform validate -no-color | ||
| # - name: terraform plan | ||
| # working-directory: ./terraform | ||
| # id: plan | ||
| # if: ${{ github.event_name == 'pull_request' }} | ||
| # run: terraform plan -no-color -input=false | ||
| # continue-on-error: true | ||
| # - name: pass or fail | ||
| # uses: actions/github-script@v6 | ||
| # if: ${{ steps.plan.outcome == 'failure' }} | ||
| # with: | ||
| # script: | | ||
| # core.setFailed('Plan failed!') | ||
| # - name: terraform apply | ||
| # id: apply | ||
| # working-directory: ./terraform | ||
| # if: github.event_name == 'pull_request' | ||
| # run: terraform apply -auto-approve -input=false |
This file contains hidden or 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,12 @@ | ||
| zip -r "chefit-backend-$1.zip" ./backend | ||
|
|
||
| aws s3 cp "flaskbb_deploy-$1.zip" s3://flaskbbapp | ||
|
|
||
| aws elasticbeanstalk create-application-version \ | ||
| --application-name chefit-backend \ | ||
| --version-label "ver-$1" \ | ||
| --source-bundle S3Bucket=terraform-state-chefit-notprowler,S3Key=fastapi/fastapi-app.zip | ||
|
|
||
| aws elasticbeanstalk update-environment \ | ||
| --environment-name fastapi-env \ | ||
| --version-label "ver-$1" | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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,55 @@ | ||
| { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this file should be stored on aws. |
||
| "version": 3, | ||
| "terraform_version": "1.12.0", | ||
| "backend": { | ||
| "type": "s3", | ||
| "config": { | ||
| "access_key": null, | ||
| "acl": null, | ||
| "allowed_account_ids": null, | ||
| "assume_role": null, | ||
| "assume_role_with_web_identity": null, | ||
| "bucket": "terraform-state-chefit-notprowler", | ||
| "custom_ca_bundle": null, | ||
| "dynamodb_endpoint": null, | ||
| "dynamodb_table": null, | ||
| "ec2_metadata_service_endpoint": null, | ||
| "ec2_metadata_service_endpoint_mode": null, | ||
| "encrypt": null, | ||
| "endpoint": null, | ||
| "endpoints": null, | ||
| "forbidden_account_ids": null, | ||
| "force_path_style": null, | ||
| "http_proxy": null, | ||
| "https_proxy": null, | ||
| "iam_endpoint": null, | ||
| "insecure": null, | ||
| "key": "fastapi/terraform.tfstate", | ||
| "kms_key_id": null, | ||
| "max_retries": null, | ||
| "no_proxy": null, | ||
| "profile": null, | ||
| "region": "us-east-1", | ||
| "retry_mode": null, | ||
| "secret_key": null, | ||
| "shared_config_files": null, | ||
| "shared_credentials_file": null, | ||
| "shared_credentials_files": null, | ||
| "skip_credentials_validation": null, | ||
| "skip_metadata_api_check": null, | ||
| "skip_region_validation": null, | ||
| "skip_requesting_account_id": null, | ||
| "skip_s3_checksum": null, | ||
| "sse_customer_key": null, | ||
| "sts_endpoint": null, | ||
| "sts_region": null, | ||
| "token": null, | ||
| "use_dualstack_endpoint": null, | ||
| "use_fips_endpoint": null, | ||
| "use_lockfile": null, | ||
| "use_path_style": null, | ||
| "workspace_key_prefix": null | ||
| }, | ||
| "hash": 1465801253 | ||
| } | ||
| } | ||
This file contains hidden or 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,7 @@ | ||
| terraform { | ||
| backend "s3" { | ||
| bucket = "terraform-state-chefit-notprowler" | ||
| key = "fastapi/terraform.tfstate" | ||
| region = "us-east-1" | ||
| } | ||
| } |
This file contains hidden or 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,22 @@ | ||
| # resource "aws_elastic_beanstalk_application" "application" { | ||
| # name = "chefit-backend" | ||
| # } | ||
|
|
||
| # resource "aws_elastic_beanstalk_environment" "environment" { | ||
| # name = "fastapi-env" | ||
| # cname_prefix = "notprowlerfastapi" | ||
| # application = aws_elastic_beanstalk_application.application.name | ||
| # solution_stack_name = "64bit Amazon Linux 2023 v4.5.1 running Python 3.11" | ||
|
|
||
| # setting { | ||
| # namespace = "aws:autoscaling:launchconfiguration" | ||
| # name = "IamInstanceProfile" | ||
| # value = "aws-elasticbeanstalk-ec2-role" | ||
| # } | ||
|
|
||
| # setting { | ||
| # namespace = "aws:elasticbeanstalk:container:python" | ||
| # name = "WSGIPath" | ||
| # value = "main:app" | ||
| # } | ||
| # } |
This file contains hidden or 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,3 @@ | ||
| provider "aws" { | ||
| region = "us-east-1" | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a copy and paste and definitely doesn't work since you don't have permissions to the flaskbbapp
this file actually has no role in deployment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hello @navteniev This file is not being used in the workflow.