Skip to content
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

Environment #7

Merged
merged 32 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f23d6f5
Testing branch protection
jarrod-lowe Aug 3, 2024
a9d45e9
Merge remote-tracking branch 'origin/main' into work
jarrod-lowe Aug 3, 2024
5db6869
First workflow
jarrod-lowe Aug 3, 2024
219dcc8
Merge remote-tracking branch 'origin/main' into work
jarrod-lowe Aug 3, 2024
c419668
First workflow - fixes
jarrod-lowe Aug 3, 2024
76219fb
Pin versions
jarrod-lowe Aug 3, 2024
0ec4389
Merge remote-tracking branch 'origin/main' into work
jarrod-lowe Aug 3, 2024
ed878c1
Merge remote-tracking branch 'origin/main' into work
jarrod-lowe Aug 3, 2024
76cb3c0
Environment
jarrod-lowe Aug 3, 2024
6324760
Create test workflaow
jarrod-lowe Aug 3, 2024
9ba670c
more test workflaow
jarrod-lowe Aug 3, 2024
2964ae8
more test workflaow
jarrod-lowe Aug 3, 2024
0fee3b4
more test workflaow
jarrod-lowe Aug 3, 2024
4342c98
more test workflaow
jarrod-lowe Aug 3, 2024
4d1c07e
more test workflaow
jarrod-lowe Aug 3, 2024
6c0e5c5
more test workflaow
jarrod-lowe Aug 3, 2024
43ffd05
more test workflaow
jarrod-lowe Aug 3, 2024
1d64b27
more test workflaow
jarrod-lowe Aug 4, 2024
ed634bd
more test workflaow
jarrod-lowe Aug 4, 2024
cebc1ad
more test workflaow
jarrod-lowe Aug 4, 2024
b0dbe66
more test workflaow
jarrod-lowe Aug 10, 2024
dd6b970
more test workflaow
jarrod-lowe Aug 10, 2024
d1ee7cb
more test workflaow
jarrod-lowe Aug 10, 2024
528dc5e
more test workflaow
jarrod-lowe Aug 10, 2024
6def01c
Merge remote-tracking branch 'origin/main' into work
jarrod-lowe Aug 10, 2024
56c8a11
more test workflaow
jarrod-lowe Aug 10, 2024
3dbfb52
more test workflaow
jarrod-lowe Aug 10, 2024
b177f8c
more test workflaow
jarrod-lowe Aug 10, 2024
7a36c0b
more test workflaow
jarrod-lowe Aug 10, 2024
c10a13a
more test workflaow
jarrod-lowe Aug 10, 2024
7df8622
more test workflaow
jarrod-lowe Aug 10, 2024
9f42d2d
more test workflaow
jarrod-lowe Aug 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/environment-main-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Environment Main - Apply

on:
push:
branches:
- main

permissions:
id-token: write
contents: read
pull-requests: write

jobs:
envtest:
name: Environment Main - Apply
runs-on: ubuntu-latest
environment: main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@9a9194f87191a7e9055e3e9b95b8cfb13023bb08
- name: Configure AWS Access
uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838
with:
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT }}:role/GitHubAction-Wildsea@${{ vars.ENVIRONMENT }}
role-session-name: GitHubTest
aws-region: ${{ vars.AWS_REGION }}
- name: terraform plan
uses: dflook/terraform-apply@@c3f4d3e8d5a1a5b8d5e4e3e7f8f2b3a1c4e9d3f2
with:
path: terraform/environment/github
variables: |
aws_account="${{ vars.AWS_ACCOUNT }}"
aws_region="${{ vars.AWS_REGION }}"
state_bucket="${{ vars.STATE_BUCKET }}"
environment="${{ vars.ENVIRONMENT }}"
backend_config:
bucket=${{ vars.STATE_BUCKET }}
key=${{ vars.ENVIRONMENT }}/terraform.tfstate
region=${{ vars.AWS_REGION }}
39 changes: 39 additions & 0 deletions .github/workflows/environment-main-plan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Environment Main - Plan

on:
pull_request: {}

permissions:
id-token: write
contents: read
pull-requests: write

jobs:
envtest:
name: Environment Main - Plan
runs-on: ubuntu-latest
environment: main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@9a9194f87191a7e9055e3e9b95b8cfb13023bb08
- name: Configure AWS Access
uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838
with:
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT }}:role/GitHubAction-Wildsea
role-session-name: GitHubTest
aws-region: ${{ vars.AWS_REGION }}
- name: terraform plan
uses: dflook/terraform-plan@d9df4f6c2484e709ba7ffaa16c98a6906f4760cd
with:
path: terraform/environment/github
variables: |
aws_account="${{ vars.AWS_ACCOUNT }}"
aws_region="${{ vars.AWS_REGION }}"
state_bucket="${{ vars.STATE_BUCKET }}"
environment="${{ vars.ENVIRONMENT }}"
backend_config:
bucket=${{ vars.STATE_BUCKET }}
key=${{ vars.ENVIRONMENT }}/terraform.tfstate
region=${{ vars.AWS_REGION }}
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,18 @@ To set up a github repository:
* Add "Codacy Static Code Analysis" to status checks that are required
* Block force pushes
* TODO: Require code scanning results
* Install <https://github.com/apps/renovate> into the repo
* Under settings, "Set up code scanning"
* Enable everything exeept Dependabot version updates
* Set up CodeQL to default
* Set the Protection rules to Any/Any
* Create an AWS Account for deployment
* Set up OIDC as per <https://aws.amazon.com/blogs/security/use-iam-roles-to-connect-github-actions-to-actions-in-aws/>
* Restrict it to the repo and branch main
* Add AdministratorAccess, for now, and call it GitHubAccess-Wildsea@main
* Add another role with ReadyOnlyAccess, don't restrict the branch, and call it GitHubAccess-Wildsea
* Add an environment "main"
* Add an Environment Variable in the environment "AWS_ACCOUNT" with the ID of the AWS Account
* Add an Environment Variable in the environment "AWS_REGION" with the AWS Region you want to use
* Add an Environment Variable in the environment "STATE_BUCKET" with the name of the state bucket you created
* Add an Environment Variable in the environment "ENVIRONMENT" with the name of the environment
3 changes: 2 additions & 1 deletion renovate.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended"
"config:recommended",
":dependencyDashboard"
]
}
43 changes: 43 additions & 0 deletions terraform/environment/github/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions terraform/environment/github/main.tf
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
resource "null_resource" "test" {}

variable "aws_account" {
description = "ID of the AWS Account"
type = string
sensitive = true
}

variable "aws_region" {
description = "AWS Region name"
type = string
sensitive = true
}

variable "state_bucket" {
description = "Name of the S3 state bucket"
type = string
}

variable "environment" {
description = "Name of the Environment"
type = string
}

terraform {
backend "s3" {
// region, bucket and key come from -backend-config
}
}

provider "aws" {
assume_role {
role_arn = "arn:aws:iam::${var.aws_account}:role/GitHubAction-Wildsea"
}
}
Loading