Skip to content

Commit

Permalink
sleep VPC in terraform DO
Browse files Browse the repository at this point in the history
  • Loading branch information
MozeBaltyk committed May 24, 2024
1 parent 203ba1c commit 9b76376
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/stage_airgap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,10 @@ jobs:
if: always()

steps:
- name: Delay half an hour
- name: Delay 10min
uses: whatnick/wait-action@master
with:
time: '1800s'
time: '600s'

cleanup:
name: Cleanup
Expand Down
38 changes: 19 additions & 19 deletions .github/workflows/stage_online.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ jobs:
name: inventory
path: |
${{ github.workspace }}/test/inventory/hosts.ini
${{ github.workspace }}/DO/infra/.key.private
${{ github.workspace }}/DO/infra/.key.pub
if-no-files-found: error

reachable:
Expand Down Expand Up @@ -147,12 +149,10 @@ jobs:
- name: Get key and hosts.ini
run: |
echo "$SSH_KEY" > .key
chmod 400 .key
cp ${{ github.workspace }}/hosts.ini inventory/hosts.ini
cp ${{ github.workspace }}/.key.private ${{ github.workspace }}/DO/infra/.key.private
cp ${{ github.workspace }}/.key.pub ${{ github.workspace }}/DO/infra/.key.pub
shell: bash
env:
SSH_KEY: ${{secrets.SSH_PRIVATE_KEY}}

- name: Test if reachable
run: |
Expand Down Expand Up @@ -189,12 +189,10 @@ jobs:

- name: Get key and hosts.ini
run: |
echo "$SSH_KEY" > .key
chmod 400 .key
cp ${{ github.workspace }}/hosts.ini inventory/hosts.ini
cp ${{ github.workspace }}/.key.private ${{ github.workspace }}/DO/infra/.key.private
cp ${{ github.workspace }}/.key.pub ${{ github.workspace }}/DO/infra/.key.pub
shell: bash
env:
SSH_KEY: ${{secrets.SSH_PRIVATE_KEY}}

- name: Run playbook install.yml
run: |
Expand Down Expand Up @@ -234,12 +232,10 @@ jobs:

- name: Get key and hosts.ini
run: |
echo "$SSH_KEY" > .key
chmod 400 .key
cp ${{ github.workspace }}/hosts.ini inventory/hosts.ini
cp ${{ github.workspace }}/.key.private ${{ github.workspace }}/DO/infra/.key.private
cp ${{ github.workspace }}/.key.pub ${{ github.workspace }}/DO/infra/.key.pub
shell: bash
env:
SSH_KEY: ${{secrets.SSH_PRIVATE_KEY}}

- name: Install dependencies
run: |
Expand All @@ -260,10 +256,10 @@ jobs:
if: always()

steps:
- name: Delay half an hour
- name: Delay 10min
uses: whatnick/wait-action@master
with:
time: '1800s'
time: '600s'

cleanup:
name: Cleanup
Expand All @@ -286,13 +282,17 @@ jobs:
with:
terraform_version: "1.7.3"

- name: Get key
- name: Download inventory
uses: actions/download-artifact@v4
with:
name: inventory

- name: Get key and hosts.ini
run: |
echo "$SSH_KEY" > .key
chmod 400 .key
cp ${{ github.workspace }}/hosts.ini inventory/hosts.ini
cp ${{ github.workspace }}/.key.private ${{ github.workspace }}/DO/infra/.key.private
cp ${{ github.workspace }}/.key.pub ${{ github.workspace }}/DO/infra/.key.pub
shell: bash
env:
SSH_KEY: ${{secrets.SSH_PRIVATE_KEY}}

- name: Terraform Init
id: init
Expand Down
7 changes: 4 additions & 3 deletions test/DO/infra/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ resource "digitalocean_vpc" "rkub-project-network" {
}

# https://github.com/digitalocean/terraform-provider-digitalocean/issues/446
resource "time_sleep" "wait_200_seconds_to_destroy" {
resource "time_sleep" "wait_for_vpc" {
depends_on = [digitalocean_vpc.rkub-project-network]
destroy_duration = "200s"
destroy_duration = "200s" # Adjust duration as needed
create_duration = "30s" # Adjust duration as needed
}
resource "null_resource" "placeholder" {
depends_on = [time_sleep.wait_200_seconds_to_destroy]
depends_on = [time_sleep.wait_for_vpc]
}
#

Expand Down

0 comments on commit 9b76376

Please sign in to comment.