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

feat: separate dev and prod environments for daily snapshots #306

Merged
merged 7 commits into from
Oct 17, 2023

Conversation

lemmih
Copy link
Contributor

@lemmih lemmih commented Oct 6, 2023

Summary of changes
Changes introduced in this pull request:

  • add separate terraform file for setting up a development deployment that is separate from the production deployment.

Reference issue to close (if applicable)

Closes

Other information and links

@github-actions
Copy link

github-actions bot commented Oct 6, 2023

Forest: Snapshot Service Infrastructure Plan: success

Show Plan
module.daily_snapshot.data.local_file.init: Reading...
module.daily_snapshot.data.digitalocean_project.forest_project: Reading...
module.daily_snapshot.data.digitalocean_ssh_keys.keys: Reading...
module.daily_snapshot.data.local_file.init: Read complete after 0s [id=4ac94881cf28678fd719534880558c2125ca2ec7]
module.daily_snapshot.data.external.sources_tar: Reading...
module.daily_snapshot.data.external.sources_tar: Read complete after 0s [id=-]
module.daily_snapshot.data.local_file.sources: Reading...
module.daily_snapshot.data.local_file.sources: Read complete after 0s [id=b20c68cc73c1ec2e9562c37172ca302a4b673ef9]
module.daily_snapshot.data.digitalocean_ssh_keys.keys: Read complete after 0s [id=ssh_keys/14512061520513425405]
module.daily_snapshot.digitalocean_droplet.forest: Refreshing state... [id=379355327]
module.daily_snapshot.digitalocean_firewall.forest-firewall: Refreshing state... [id=861ab34e-5c37-4071-a873-25bf275cbf7e]
module.daily_snapshot.data.digitalocean_project.forest_project: Read complete after 1s [id=da5e6601-7fd9-4d02-951e-390f7feb3411]
module.daily_snapshot.digitalocean_project_resources.connect_forest_project: Refreshing state... [id=da5e6601-7fd9-4d02-951e-390f7feb3411]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  ~ update in-place
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # module.daily_snapshot.digitalocean_droplet.forest must be replaced
-/+ resource "digitalocean_droplet" "forest" {
      ~ created_at           = "2023-10-12T14:06:40Z" -> (known after apply)
      ~ disk                 = 200 -> (known after apply)
      ~ id                   = "379355327" -> (known after apply)
      ~ ipv4_address         = "206.81.28.37" -> (known after apply)
      ~ ipv4_address_private = "10.135.0.4" -> (known after apply)
      + ipv6_address         = (known after apply)
      ~ locked               = false -> (known after apply)
      ~ memory               = 16384 -> (known after apply)
        name                 = "forest-snapshot"
      ~ price_hourly         = 0.125 -> (known after apply)
      ~ price_monthly        = 84 -> (known after apply)
      ~ private_networking   = true -> (known after apply)
      ~ status               = "active" -> (known after apply)
        tags                 = [
            "iac",
        ]
      ~ urn                  = "do:droplet:379355327" -> (known after apply)
      ~ user_data            = "661618501ccb69e3f9fb67a4a4f885c6fb1c9724" -> "45af711bf3e8fd2eb3ad95d66d4417c6d3e610cd" # forces replacement
      ~ vcpus                = 4 -> (known after apply)
      ~ volume_ids           = [] -> (known after apply)
      ~ vpc_uuid             = "46a525ac-fd37-47ea-bb10-95c1db0055f7" -> (known after apply)
        # (9 unchanged attributes hidden)
    }

  # module.daily_snapshot.digitalocean_firewall.forest-firewall will be updated in-place
  ~ resource "digitalocean_firewall" "forest-firewall" {
      ~ droplet_ids     = [
          - 379355327,
        ] -> (known after apply)
        id              = "861ab34e-5c37-4071-a873-25bf275cbf7e"
        name            = "forest-snapshot"
        tags            = []
        # (3 unchanged attributes hidden)

        # (6 unchanged blocks hidden)
    }

  # module.daily_snapshot.digitalocean_project_resources.connect_forest_project will be updated in-place
  ~ resource "digitalocean_project_resources" "connect_forest_project" {
        id        = "da5e6601-7fd9-4d02-951e-390f7feb3411"
      ~ resources = [
          - "do:droplet:379355327",
        ] -> (known after apply)
        # (1 unchanged attribute hidden)
    }

Plan: 1 to add, 2 to change, 1 to destroy.

Changes to Outputs:
  ~ ip = [
      - [
          - "206.81.28.37",
        ],
      + [
          + (known after apply),
        ],
    ]

─────────────────────────────────────────────────────────────────────────────

Saved the plan to: tfplan

To perform exactly these actions, run the following command to apply:
    terraform apply "tfplan"

@github-actions
Copy link

github-actions bot commented Oct 6, 2023

Forest: Snapshot Service Infrastructure Plan: success

Show Plan
module.daily_snapshot.data.local_file.init: Reading...
module.daily_snapshot.data.external.sources_tar: Reading...
module.daily_snapshot.data.local_file.init: Read complete after 0s [id=0f916ba60130b7c9f9756ff2e473a2199f4675b2]
module.daily_snapshot.data.external.sources_tar: Read complete after 0s [id=-]
module.daily_snapshot.data.local_file.sources: Reading...
module.daily_snapshot.data.digitalocean_ssh_keys.keys: Reading...
module.daily_snapshot.data.local_file.sources: Read complete after 0s [id=704479cb67100a92d5b64bf6990080dd2e8c0b8c]
module.daily_snapshot.data.digitalocean_project.forest_project: Reading...
module.daily_snapshot.data.digitalocean_ssh_keys.keys: Read complete after 0s [id=ssh_keys/14512061520513425405]
module.daily_snapshot.digitalocean_droplet.forest: Refreshing state... [id=378180002]
module.daily_snapshot.digitalocean_firewall.forest-firewall: Refreshing state... [id=badd14b2-2313-4342-968c-58e41dc7ee51]
module.daily_snapshot.data.digitalocean_project.forest_project: Read complete after 1s [id=da5e6601-7fd9-4d02-951e-390f7feb3411]
module.daily_snapshot.digitalocean_project_resources.connect_forest_project: Refreshing state... [id=da5e6601-7fd9-4d02-951e-390f7feb3411]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  ~ update in-place
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # module.daily_snapshot.digitalocean_droplet.forest must be replaced
-/+ resource "digitalocean_droplet" "forest" {
      ~ created_at           = "2023-10-05T15:50:55Z" -> (known after apply)
      ~ disk                 = 200 -> (known after apply)
      ~ id                   = "378180002" -> (known after apply)
      ~ ipv4_address         = "134.209.241.203" -> (known after apply)
      ~ ipv4_address_private = "10.135.0.5" -> (known after apply)
      + ipv6_address         = (known after apply)
      ~ locked               = false -> (known after apply)
      ~ memory               = 16384 -> (known after apply)
        name                 = "forest-snapshot"
      ~ price_hourly         = 0.125 -> (known after apply)
      ~ price_monthly        = 84 -> (known after apply)
      ~ private_networking   = true -> (known after apply)
      ~ status               = "active" -> (known after apply)
        tags                 = [
            "iac",
        ]
      ~ urn                  = "do:droplet:378180002" -> (known after apply)
      ~ user_data            = "c3534828b7ae96804f160a636412c12d7311c99b" -> "8e283f8de629397c01762dfcc6f96f35cf997058" # forces replacement
      ~ vcpus                = 4 -> (known after apply)
      ~ volume_ids           = [] -> (known after apply)
      ~ vpc_uuid             = "46a525ac-fd37-47ea-bb10-95c1db0055f7" -> (known after apply)
        # (9 unchanged attributes hidden)
    }

  # module.daily_snapshot.digitalocean_firewall.forest-firewall will be updated in-place
  ~ resource "digitalocean_firewall" "forest-firewall" {
      ~ droplet_ids     = [
          - 378180002,
        ] -> (known after apply)
        id              = "badd14b2-2313-4342-968c-58e41dc7ee51"
        name            = "forest-snapshot"
        tags            = []
        # (3 unchanged attributes hidden)

        # (6 unchanged blocks hidden)
    }

  # module.daily_snapshot.digitalocean_project_resources.connect_forest_project will be updated in-place
  ~ resource "digitalocean_project_resources" "connect_forest_project" {
        id        = "da5e6601-7fd9-4d02-951e-390f7feb3411"
      ~ resources = [
          - "do:droplet:378180002",
        ] -> (known after apply)
        # (1 unchanged attribute hidden)
    }

Plan: 1 to add, 2 to change, 1 to destroy.

Changes to Outputs:
  ~ ip = [
      - [
          - "134.209.241.203",
        ],
      + [
          + null,
        ],
    ]

─────────────────────────────────────────────────────────────────────────────

Saved the plan to: tfplan

To perform exactly these actions, run the following command to apply:
    terraform apply "tfplan"

@github-actions
Copy link

github-actions bot commented Oct 6, 2023

Forest: Snapshot Service Infrastructure Plan: success

Show Plan
module.daily_snapshot.data.local_file.init: Reading...
module.daily_snapshot.data.local_file.init: Read complete after 0s [id=0f916ba60130b7c9f9756ff2e473a2199f4675b2]
module.daily_snapshot.data.external.sources_tar: Reading...
module.daily_snapshot.data.external.sources_tar: Read complete after 0s [id=-]
module.daily_snapshot.data.digitalocean_ssh_keys.keys: Reading...
module.daily_snapshot.data.digitalocean_project.forest_project: Reading...
module.daily_snapshot.data.local_file.sources: Reading...
module.daily_snapshot.data.local_file.sources: Read complete after 0s [id=704479cb67100a92d5b64bf6990080dd2e8c0b8c]
module.daily_snapshot.data.digitalocean_ssh_keys.keys: Read complete after 0s [id=ssh_keys/14512061520513425405]
module.daily_snapshot.digitalocean_droplet.forest: Refreshing state... [id=378180002]
module.daily_snapshot.digitalocean_firewall.forest-firewall: Refreshing state... [id=badd14b2-2313-4342-968c-58e41dc7ee51]
module.daily_snapshot.data.digitalocean_project.forest_project: Read complete after 1s [id=da5e6601-7fd9-4d02-951e-390f7feb3411]
module.daily_snapshot.digitalocean_project_resources.connect_forest_project: Refreshing state... [id=da5e6601-7fd9-4d02-951e-390f7feb3411]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  ~ update in-place
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # module.daily_snapshot.digitalocean_droplet.forest must be replaced
-/+ resource "digitalocean_droplet" "forest" {
      ~ created_at           = "2023-10-05T15:50:55Z" -> (known after apply)
      ~ disk                 = 200 -> (known after apply)
      ~ id                   = "378180002" -> (known after apply)
      ~ ipv4_address         = "134.209.241.203" -> (known after apply)
      ~ ipv4_address_private = "10.135.0.5" -> (known after apply)
      + ipv6_address         = (known after apply)
      ~ locked               = false -> (known after apply)
      ~ memory               = 16384 -> (known after apply)
        name                 = "forest-snapshot"
      ~ price_hourly         = 0.125 -> (known after apply)
      ~ price_monthly        = 84 -> (known after apply)
      ~ private_networking   = true -> (known after apply)
      ~ status               = "active" -> (known after apply)
        tags                 = [
            "iac",
        ]
      ~ urn                  = "do:droplet:378180002" -> (known after apply)
      ~ user_data            = "c3534828b7ae96804f160a636412c12d7311c99b" -> "8e283f8de629397c01762dfcc6f96f35cf997058" # forces replacement
      ~ vcpus                = 4 -> (known after apply)
      ~ volume_ids           = [] -> (known after apply)
      ~ vpc_uuid             = "46a525ac-fd37-47ea-bb10-95c1db0055f7" -> (known after apply)
        # (9 unchanged attributes hidden)
    }

  # module.daily_snapshot.digitalocean_firewall.forest-firewall will be updated in-place
  ~ resource "digitalocean_firewall" "forest-firewall" {
      ~ droplet_ids     = [
          - 378180002,
        ] -> (known after apply)
        id              = "badd14b2-2313-4342-968c-58e41dc7ee51"
        name            = "forest-snapshot"
        tags            = []
        # (3 unchanged attributes hidden)

        # (6 unchanged blocks hidden)
    }

  # module.daily_snapshot.digitalocean_project_resources.connect_forest_project will be updated in-place
  ~ resource "digitalocean_project_resources" "connect_forest_project" {
        id        = "da5e6601-7fd9-4d02-951e-390f7feb3411"
      ~ resources = [
          - "do:droplet:378180002",
        ] -> (known after apply)
        # (1 unchanged attribute hidden)
    }

Plan: 1 to add, 2 to change, 1 to destroy.

Changes to Outputs:
  ~ ip = [
      - [
          - "134.209.241.203",
        ],
      + [
          + null,
        ],
    ]

─────────────────────────────────────────────────────────────────────────────

Saved the plan to: tfplan

To perform exactly these actions, run the following command to apply:
    terraform apply "tfplan"

@github-actions
Copy link

github-actions bot commented Oct 6, 2023

Forest: Snapshot Service Infrastructure Plan: success

Show Plan
module.daily_snapshot.data.external.sources_tar: Reading...
module.daily_snapshot.data.digitalocean_project.forest_project: Reading...
module.daily_snapshot.data.digitalocean_ssh_keys.keys: Reading...
module.daily_snapshot.data.local_file.init: Reading...
module.daily_snapshot.data.external.sources_tar: Read complete after 0s [id=-]
module.daily_snapshot.data.local_file.init: Read complete after 0s [id=0f916ba60130b7c9f9756ff2e473a2199f4675b2]
module.daily_snapshot.data.local_file.sources: Reading...
module.daily_snapshot.data.local_file.sources: Read complete after 0s [id=704479cb67100a92d5b64bf6990080dd2e8c0b8c]
module.daily_snapshot.data.digitalocean_ssh_keys.keys: Read complete after 0s [id=ssh_keys/14512061520513425405]
module.daily_snapshot.digitalocean_droplet.forest: Refreshing state... [id=378180002]
module.daily_snapshot.digitalocean_firewall.forest-firewall: Refreshing state... [id=badd14b2-2313-4342-968c-58e41dc7ee51]
module.daily_snapshot.data.digitalocean_project.forest_project: Read complete after 2s [id=da5e6601-7fd9-4d02-951e-390f7feb3411]
module.daily_snapshot.digitalocean_project_resources.connect_forest_project: Refreshing state... [id=da5e6601-7fd9-4d02-951e-390f7feb3411]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  ~ update in-place
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # module.daily_snapshot.digitalocean_droplet.forest must be replaced
-/+ resource "digitalocean_droplet" "forest" {
      ~ created_at           = "2023-10-05T15:50:55Z" -> (known after apply)
      ~ disk                 = 200 -> (known after apply)
      ~ id                   = "378180002" -> (known after apply)
      ~ ipv4_address         = "134.209.241.203" -> (known after apply)
      ~ ipv4_address_private = "10.135.0.5" -> (known after apply)
      + ipv6_address         = (known after apply)
      ~ locked               = false -> (known after apply)
      ~ memory               = 16384 -> (known after apply)
        name                 = "forest-snapshot"
      ~ price_hourly         = 0.125 -> (known after apply)
      ~ price_monthly        = 84 -> (known after apply)
      ~ private_networking   = true -> (known after apply)
      ~ status               = "active" -> (known after apply)
        tags                 = [
            "iac",
        ]
      ~ urn                  = "do:droplet:378180002" -> (known after apply)
      ~ user_data            = "c3534828b7ae96804f160a636412c12d7311c99b" -> "8e283f8de629397c01762dfcc6f96f35cf997058" # forces replacement
      ~ vcpus                = 4 -> (known after apply)
      ~ volume_ids           = [] -> (known after apply)
      ~ vpc_uuid             = "46a525ac-fd37-47ea-bb10-95c1db0055f7" -> (known after apply)
        # (9 unchanged attributes hidden)
    }

  # module.daily_snapshot.digitalocean_firewall.forest-firewall will be updated in-place
  ~ resource "digitalocean_firewall" "forest-firewall" {
      ~ droplet_ids     = [
          - 378180002,
        ] -> (known after apply)
        id              = "badd14b2-2313-4342-968c-58e41dc7ee51"
        name            = "forest-snapshot"
        tags            = []
        # (3 unchanged attributes hidden)

        # (6 unchanged blocks hidden)
    }

  # module.daily_snapshot.digitalocean_project_resources.connect_forest_project will be updated in-place
  ~ resource "digitalocean_project_resources" "connect_forest_project" {
        id        = "da5e6601-7fd9-4d02-951e-390f7feb3411"
      ~ resources = [
          - "do:droplet:378180002",
        ] -> (known after apply)
        # (1 unchanged attribute hidden)
    }

Plan: 1 to add, 2 to change, 1 to destroy.

Changes to Outputs:
  ~ ip = [
      - [
          - "134.209.241.203",
        ],
      + [
          + null,
        ],
    ]

─────────────────────────────────────────────────────────────────────────────

Saved the plan to: tfplan

To perform exactly these actions, run the following command to apply:
    terraform apply "tfplan"

@lemmih lemmih marked this pull request as ready for review October 6, 2023 08:30
@lemmih lemmih requested a review from a team as a code owner October 6, 2023 08:30
@lemmih lemmih requested review from LesnyRumcajs and elmattic and removed request for a team October 6, 2023 08:30
Copy link
Member

@LesnyRumcajs LesnyRumcajs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that prod is in prod/, how about moving dev to dev/ for consistency?

@lemmih
Copy link
Contributor Author

lemmih commented Oct 6, 2023

Given that prod is in prod/, how about moving dev to dev/ for consistency?

I kind of like that prod/ is hidden away and the dev files are always the first thing you see.

Copy link
Contributor

@samuelarogbonlo samuelarogbonlo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about the same set-up for other services?

@lemmih
Copy link
Contributor Author

lemmih commented Oct 6, 2023

what about the same set-up for other services?

That will come later.

@LesnyRumcajs
Copy link
Member

@lemmih mergio?

@lemmih
Copy link
Contributor Author

lemmih commented Oct 16, 2023

@lemmih mergio?

Yeah, just have to fix the merge conflict.

@lemmih
Copy link
Contributor Author

lemmih commented Oct 16, 2023

@lemmih mergio?

Yeah, just have to fix the merge conflict.

Fixed. That was a lot easier than I had feared.

@lemmih lemmih enabled auto-merge (squash) October 16, 2023 08:37
@LesnyRumcajs LesnyRumcajs disabled auto-merge October 17, 2023 08:41
@LesnyRumcajs LesnyRumcajs merged commit 998d65e into main Oct 17, 2023
7 checks passed
@LesnyRumcajs LesnyRumcajs deleted the lemmih/terraform-dev-environment branch January 22, 2024 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants