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

adding tf pipelines #1

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 0 additions & 16 deletions .devcontainer/Dockerfile

This file was deleted.

18 changes: 0 additions & 18 deletions .devcontainer/devcontainer.json

This file was deleted.

17 changes: 0 additions & 17 deletions .devcontainer/save-config.sh

This file was deleted.

21 changes: 0 additions & 21 deletions .devcontainer/start-openvpn.sh

This file was deleted.

86 changes: 86 additions & 0 deletions .github/workflows/infra.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: SetUp the sales demo

on:
workflow_dispatch:
inputs:
module:
description: Module to run
type: choice
default: foundation
options:
- admin-tenant
- aws-services
- app
cmd:
description: Command to run
type: choice
default: plan
options:
- plan
- apply
- destroy
environment:
description: Environment to deploy to
type: environment
default: salesdemo
workspace:
description: Workspace to run
type: string
default: default

workflow_call:
inputs:
cmd:
description: Command to run
type: string
default: plan
environment:
description: Environment to deploy to
type: string
default: dev
module:
description: Module to run
type: string
default: admin-tenant
workspace:
description: Workspace to run
type: string
default: default
secrets:
DUPLO_TOKEN:
description: Duplo Token
required: true
jobs:
module:
name: ${{ inputs.cmd }} ${{ inputs.workspace }} foundation
runs-on: ubuntu-latest
environment:
name: ${{ inputs.environment }}
env:
DUPLO_TOKEN: ${{ secrets.DUPLO_TOKEN }}
DUPLO_HOST: ${{ vars.DUPLO_HOST }}
DUPLO_TENANT: ${{ vars.DUPLO_TENANT }}
TF_CLI_ARGS_apply: -parallelism=1
steps:

- name: Checkout source code
uses: actions/checkout@v3

- name: Duplo and AWS Setup
uses: duplocloud/actions/setup@main

- name: Terraform Setup
uses: duplocloud/actions/setup-terraform@main

- name: TF Validate Module
uses: duplocloud/actions/terraform-module@main
with:
module: modules/foundation
test: false

- name: TF Execute Module
uses: duplocloud/actions/terraform-exec@main
with:
module: iac/${{ inputs.module }}
workspace: ${{ inputs.workspace }}
command: ${{ inputs.cmd }}
26 changes: 0 additions & 26 deletions docs/Steps.md

This file was deleted.

37 changes: 37 additions & 0 deletions iac/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log
duplo.log

# Exclude all .tfvars files, which are likely to contain sentitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
#
#*.tfvars

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
#
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Ignore CLI configuration files
.terraformrc
terraform.rc
target/**
1 change: 1 addition & 0 deletions iac/.terraform-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.5.5
44 changes: 44 additions & 0 deletions iac/terraform/admin-tenant/.terraform.lock.hcl

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

8 changes: 8 additions & 0 deletions iac/terraform/admin-tenant/backend.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {
backend "s3" {
region = "us-west-2"
key = "tenant"
workspace_key_prefix = "admin:"
encrypt = true
}
}
23 changes: 23 additions & 0 deletions iac/terraform/admin-tenant/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
locals {
plan_id = var.infra_name
tenant_name = terraform.workspace
region = data.duplocloud_infrastructure.infra.region
}

data "duplocloud_infrastructure" "infra" {
infra_name = var.infra_name
}

resource "duplocloud_tenant" "tenant" {
account_name = local.tenant_name
plan_id = local.plan_id
allow_deletion = true
}

resource "duplocloud_tenant_config" "tenant-config" {
tenant_id = duplocloud_tenant.tenant.tenant_id
setting {
key = "delete_protection"
value = "true"
}
}
22 changes: 22 additions & 0 deletions iac/terraform/admin-tenant/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
output "tenant_name" {
value = duplocloud_tenant.tenant.account_name
description = "The tenant name"
}
output "tenant_id" {
value = duplocloud_tenant.tenant.tenant_id
description = "The tenant ID"
}

output "infra_name" {
value = data.duplocloud_infrastructure.infra.infra_name
description = "The duplo infra name."
}
output "vpc_id" {
value = data.duplocloud_infrastructure.infra.vpc_id
description = "The VPC or VNet ID."
}
output "region" {
value = local.region
description = "The AWS region the Tenant is located in"
}

15 changes: 15 additions & 0 deletions iac/terraform/admin-tenant/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
terraform {
required_version = ">= 1.5.5"
required_providers {
duplocloud = {
source = "duplocloud/duplocloud"
version = "~> 0.10.2"
}
}
}
provider "duplocloud" {

}
provider "aws" {
region = local.region
}
8 changes: 8 additions & 0 deletions iac/terraform/admin-tenant/vars.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
variable "region" {
default = "us-west-2"
type = string
}
variable "infra_name" {
type = string
default = "prod-infra"
}
Loading
Loading