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

CloudRunにSecretManagerを追加 #36

Merged
merged 3 commits into from
Aug 18, 2024
Merged

Conversation

Shion1305
Copy link
Owner

  • ✨ (terraform) google_secret_manager_secret
  • 🔧 (terraform) attach envs to cloudrun

ImageをBuildする際には.envを含めず、
動かす時にのみAttachする形式に変更

data "google_secret_manager_secret" "line_client_id" {
secret_id = "LINE_CLIENT_ID"
}
data "google_secret_manager_secret" "line_client_secret" {

Choose a reason for hiding this comment

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

⚠️ [tflint] reported by reviewdog 🐶
data "google_secret_manager_secret" "line_client_secret" is declared but not used

data "google_secret_manager_secret" "discord_client_secret" {
secret_id = "DISCORD_CLIENT_SECRET"
}
data "google_secret_manager_secret" "discord_guild_id" {

Choose a reason for hiding this comment

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

⚠️ [tflint] reported by reviewdog 🐶
data "google_secret_manager_secret" "discord_guild_id" is declared but not used

data "google_secret_manager_secret" "discord_guild_id" {
secret_id = "DISCORD_GUILD_ID"
}
data "google_secret_manager_secret" "discord_member_role_id" {

Choose a reason for hiding this comment

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

⚠️ [tflint] reported by reviewdog 🐶
data "google_secret_manager_secret" "discord_member_role_id" is declared but not used

Copy link

github-actions bot commented Aug 18, 2024

Plan Result

CI link

Plan: 0 to add, 1 to change, 0 to destroy.
  • Update
    • google_cloud_run_v2_service.release
Change Result (Click me)
  # google_cloud_run_v2_service.release will be updated in-place
  ~ resource "google_cloud_run_v2_service" "release" {
        id                      = "projects/lumos-profile-management/locations/asia-northeast1/services/release"
        name                    = "release"
        # (30 unchanged attributes hidden)

      ~ template {
            # (9 unchanged attributes hidden)

          ~ containers {
                name        = "nuxt3-release-1"
                # (5 unchanged attributes hidden)

              + env {
                  + name = "DISCORD_AUTH_URL"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "DISCORD_AUTH_URL"
                          + version = "latest"
                        }
                    }
                }
              + env {
                  + name = "DISCORD_BOT_TOKEN"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "DISCORD_BOT_TOKEN"
                          + version = "latest"
                        }
                    }
                }
              + env {
                  + name = "DISCORD_CALLBACK_URI"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "DISCORD_CALLBACK_URI"
                          + version = "latest"
                        }
                    }
                }
              + env {
                  + name = "DISCORD_CLIENT_ID"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "DISCORD_CLIENT_ID"
                          + version = "latest"
                        }
                    }
                }
              + env {
                  + name = "DISCORD_CLIENT_SECRET"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "DISCORD_CLIENT_SECRET"
                          + version = "latest"
                        }
                    }
                }
              + env {
                  + name = "DISCORD_GUILD_ID"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "DISCORD_GUILD_ID"
                          + version = "latest"
                        }
                    }
                }
              + env {
                  + name = "DISCORD_MEMBER_ROLE_ID"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "DISCORD_MEMBER_ROLE_ID"
                          + version = "latest"
                        }
                    }
                }
              + env {
                  + name = "FIREBASE_ADMIN_CERT_PATH"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "FIREBASE_ADMIN_CERT_PATH"
                          + version = "latest"
                        }
                    }
                }
              + env {
                  + name = "JWT_SECRET"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "JWT_SECRET"
                          + version = "latest"
                        }
                    }
                }
              + env {
                  + name = "LINE_AUTH_URL"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "LINE_AUTH_URL"
                          + version = "latest"
                        }
                    }
                }
              + env {
                  + name = "LINE_CALLBACK_URI"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "LINE_CALLBACK_URI"
                          + version = "latest"
                        }
                    }
                }
              + env {
                  + name = "LINE_CLIENT_ID"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "LINE_CLIENT_ID"
                          + version = "latest"
                        }
                    }
                }
              + env {
                  + name = "LINE_CLIENT_SECRET"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "LINE_CLIENT_SECRET"
                          + version = "latest"
                        }
                    }
                }

                # (3 unchanged blocks hidden)
            }

            # (1 unchanged block hidden)
        }

        # (1 unchanged block hidden)
    }

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

Repository owner deleted a comment from github-actions bot Aug 18, 2024
Repository owner deleted a comment from github-actions bot Aug 18, 2024
Repository owner deleted a comment from github-actions bot Aug 18, 2024
Repository owner deleted a comment from github-actions bot Aug 18, 2024
Repository owner deleted a comment from github-actions bot Aug 18, 2024
Repository owner deleted a comment from github-actions bot Aug 18, 2024
Repository owner deleted a comment from github-actions bot Aug 18, 2024
Repository owner deleted a comment from github-actions bot Aug 18, 2024
Repository owner deleted a comment from github-actions bot Aug 18, 2024
Repository owner deleted a comment from github-actions bot Aug 18, 2024
@Shion1305 Shion1305 merged commit 8ef9429 into main Aug 18, 2024
3 checks passed
@Shion1305 Shion1305 deleted the shion/attach-secret-managers branch August 18, 2024 13:57
Copy link

❌ Apply Failed

CI link

It failed to parse the result.

Details (Click me)
Acquiring state lock. This may take a few moments...
data.google_secret_manager_secret.discord_client_secret: Reading...
data.google_secret_manager_secret.jwt_secret: Reading...
data.google_secret_manager_secret.discord_guild_id: Reading...
data.google_secret_manager_secret.discord_bot_token: Reading...
data.google_secret_manager_secret.line_auth_url: Reading...
data.google_secret_manager_secret.line_client_id: Reading...
data.google_secret_manager_secret.line_callback_uri: Reading...
data.google_secret_manager_secret.discord_member_role_id: Reading...
data.google_secret_manager_secret.line_client_secret: Reading...
google_artifact_registry_repository.main-repo: Refreshing state... [id=projects/lumos-profile-management/locations/asia-northeast1/repositories/main]
data.google_secret_manager_secret.discord_member_role_id: Read complete after 0s [id=projects/lumos-profile-management/secrets/DISCORD_MEMBER_ROLE_ID]
data.google_secret_manager_secret.firebase_admin_cert_path: Reading...
data.google_secret_manager_secret.line_auth_url: Read complete after 0s [id=projects/lumos-profile-management/secrets/LINE_AUTH_URL]
data.google_secret_manager_secret.line_client_id: Read complete after 0s [id=projects/lumos-profile-management/secrets/LINE_CLIENT_ID]
data.google_secret_manager_secret.discord_auth_url: Reading...
data.google_secret_manager_secret.discord_client_id: Reading...
data.google_secret_manager_secret.discord_client_secret: Read complete after 0s [id=projects/lumos-profile-management/secrets/DISCORD_CLIENT_SECRET]
data.google_secret_manager_secret.discord_callback_uri: Reading...
data.google_secret_manager_secret.line_callback_uri: Read complete after 0s [id=projects/lumos-profile-management/secrets/LINE_CALLBACK_URI]
data.google_secret_manager_secret.firebase_admin_cert_path: Read complete after 0s [id=projects/lumos-profile-management/secrets/FIREBASE_ADMIN_CERT_PATH]
data.google_secret_manager_secret.discord_auth_url: Read complete after 0s [id=projects/lumos-profile-management/secrets/DISCORD_AUTH_URL]
data.google_secret_manager_secret.discord_bot_token: Read complete after 0s [id=projects/lumos-profile-management/secrets/DISCORD_BOT_TOKEN]
data.google_secret_manager_secret.jwt_secret: Read complete after 0s [id=projects/lumos-profile-management/secrets/JWT_SECRET]
data.google_secret_manager_secret.line_client_secret: Read complete after 0s [id=projects/lumos-profile-management/secrets/LINE_CLIENT_SECRET]
data.google_secret_manager_secret.discord_guild_id: Read complete after 0s [id=projects/lumos-profile-management/secrets/DISCORD_GUILD_ID]
data.google_secret_manager_secret.discord_client_id: Read complete after 1s [id=projects/lumos-profile-management/secrets/DISCORD_CLIENT_ID]
data.google_secret_manager_secret.discord_callback_uri: Read complete after 1s [id=projects/lumos-profile-management/secrets/DISCORD_CALLBACK_URI]
google_cloud_run_v2_service.release: Refreshing state... [id=projects/lumos-profile-management/locations/asia-northeast1/services/release]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # google_cloud_run_v2_service.release will be updated in-place
  ~ resource "google_cloud_run_v2_service" "release" {
        id                      = "projects/lumos-profile-management/locations/asia-northeast1/services/release"
        name                    = "release"
        # (30 unchanged attributes hidden)

      ~ template {
            # (9 unchanged attributes hidden)

          ~ containers {
                name        = "nuxt3-release-1"
                # (5 unchanged attributes hidden)

              + env {
                  + name = "DISCORD_AUTH_URL"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "DISCORD_AUTH_URL"
                          + version = "latest"
                        }
                    }
                }
              + env {
                  + name = "DISCORD_BOT_TOKEN"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "DISCORD_BOT_TOKEN"
                          + version = "latest"
                        }
                    }
                }
              + env {
                  + name = "DISCORD_CALLBACK_URI"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "DISCORD_CALLBACK_URI"
                          + version = "latest"
                        }
                    }
                }
              + env {
                  + name = "DISCORD_CLIENT_ID"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "DISCORD_CLIENT_ID"
                          + version = "latest"
                        }
                    }
                }
              + env {
                  + name = "DISCORD_CLIENT_SECRET"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "DISCORD_CLIENT_SECRET"
                          + version = "latest"
                        }
                    }
                }
              + env {
                  + name = "DISCORD_GUILD_ID"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "DISCORD_GUILD_ID"
                          + version = "latest"
                        }
                    }
                }
              + env {
                  + name = "DISCORD_MEMBER_ROLE_ID"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "DISCORD_MEMBER_ROLE_ID"
                          + version = "latest"
                        }
                    }
                }
              + env {
                  + name = "FIREBASE_ADMIN_CERT_PATH"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "FIREBASE_ADMIN_CERT_PATH"
                          + version = "latest"
                        }
                    }
                }
              + env {
                  + name = "JWT_SECRET"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "JWT_SECRET"
                          + version = "latest"
                        }
                    }
                }
              + env {
                  + name = "LINE_AUTH_URL"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "LINE_AUTH_URL"
                          + version = "latest"
                        }
                    }
                }
              + env {
                  + name = "LINE_CALLBACK_URI"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "LINE_CALLBACK_URI"
                          + version = "latest"
                        }
                    }
                }
              + env {
                  + name = "LINE_CLIENT_ID"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "LINE_CLIENT_ID"
                          + version = "latest"
                        }
                    }
                }
              + env {
                  + name = "LINE_CLIENT_SECRET"

                  + value_source {
                      + secret_key_ref {
                          + secret  = "LINE_CLIENT_SECRET"
                          + version = "latest"
                        }
                    }
                }

                # (3 unchanged blocks hidden)
            }

            # (1 unchanged block hidden)
        }

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.
google_cloud_run_v2_service.release: Modifying... [id=projects/lumos-profile-management/locations/asia-northeast1/services/release]
google_cloud_run_v2_service.release: Still modifying... [id=projects/lumos-profile-management/locations/asia-northeast1/services/release, 10s elapsed]
╷
│ Error: Error waiting for Updating Service: Error code 13, message: Revision 'release-00024-wqs' is not ready and cannot serve traffic. spec.template.spec.containers[0].env[0].value_from.secret_key_ref.name: Permission denied on secret: projects/938038185918/secrets/DISCORD_AUTH_URL/versions/latest for Revision service account 938038185918-compute@developer.gserviceaccount.com. The service account used must be granted the 'Secret Manager Secret Accessor' role (roles/secretmanager.secretAccessor) at the secret, project or higher level.
│ spec.template.spec.containers[0].env[1].value_from.secret_key_ref.name: Permission denied on secret: projects/938038185918/secrets/DISCORD_BOT_TOKEN/versions/latest for Revision service account 938038185918-compute@developer.gserviceaccount.com. The service account used must be granted the 'Secret Manager Secret Accessor' role (roles/secretmanager.secretAccessor) at the secret, project or higher level.
│ spec.template.spec.containers[0].env[2].value_from.secret_key_ref.name: Permission denied on secret: projects/938038185918/secrets/DISCORD_CALLBACK_URI/versions/latest for Revision service account 938038185918-compute@developer.gserviceaccount.com. The service account used must be granted the 'Secret Manager Secret Accessor' role (roles/secretmanager.secretAccessor) at the secret, project or higher level.
│ spec.template.spec.containers[0].env[3].value_from.secret_key_ref.name: Permission denied on secret: projects/938038185918/secrets/DISCORD_CLIENT_ID/versions/latest for Revision service account 938038185918-compute@developer.gserviceaccount.com. The service account used must be granted the 'Secret Manager Secret Accessor' role (roles/secretmanager.secretAccessor) at the secret, project or higher level.
│ spec.template.spec.containers[0].env[4].value_from.secret_key_ref.name: Permission denied on secret: projects/938038185918/secrets/DISCORD_CLIENT_SECRET/versions/latest for Revision service account 938038185918-compute@developer.gserviceaccount.com. The service account used must be granted the 'Secret Manager Secret Accessor' role (roles/secretmanager.secretAccessor) at the secret, project or higher level.
│ spec.template.spec.containers[0].env[5].value_from.secret_key_ref.name: Permission denied on secret: projects/938038185918/secrets/DISCORD_GUILD_ID/versions/latest for Revision service account 938038185918-compute@developer.gserviceaccount.com. The service account used must be granted the 'Secret Manager Secret Accessor' role (roles/secretmanager.secretAccessor) at the secret, project or higher level.
│ spec.template.spec.containers[0].env[6].value_from.secret_key_ref.name: Permission denied on secret: projects/938038185918/secrets/DISCORD_MEMBER_ROLE_ID/versions/latest for Revision service account 938038185918-compute@developer.gserviceaccount.com. The service account used must be granted the 'Secret Manager Secret Accessor' role (roles/secretmanager.secretAccessor) at the secret, project or higher level.
│ spec.template.spec.containers[0].env[7].value_from.secret_key_ref.name: Permission denied on secret: projects/938038185918/secrets/FIREBASE_ADMIN_CERT_PATH/versions/latest for Revision service account 938038185918-compute@developer.gserviceaccount.com. The service account used must be granted the 'Secret Manager Secret Accessor' role (roles/secretmanager.secretAccessor) at the secret, project or higher level.
│ spec.template.spec.containers[0].env[8].value_from.secret_key_ref.name: Permission denied on secret: projects/938038185918/secrets/JWT_SECRET/versions/latest for Revision service account 938038185918-compute@developer.gserviceaccount.com. The service account used must be granted the 'Secret Manager Secret Accessor' role (roles/secretmanager.secretAccessor) at the secret, project or higher level.
│ spec.template.spec.containers[0].env[9].value_from.secret_key_ref.name: Permission denied on secret: projects/938038185918/secrets/LINE_AUTH_URL/versions/latest for Revision service account 938038185918-compute@developer.gserviceaccount.com. The service account used must be granted the 'Secret Manager Secret Accessor' role (roles/secretmanager.secretAccessor) at the secret, project or higher level.
│ spec.template.spec.containers[0].env[10].value_from.secret_key_ref.name: Permission denied on secret: projects/938038185918/secrets/LINE_CALLBACK_URI/versions/latest for Revision service account 938038185918-compute@developer.gserviceaccount.com. The service account used must be granted the 'Secret Manager Secret Accessor' role (roles/secretmanager.secretAccessor) at the secret, project or higher level.
│ spec.template.spec.containers[0].env[11].value_from.secret_key_ref.name: Permission denied on secret: projects/938038185918/secrets/LINE_CLIENT_ID/versions/latest for Revision service account 938038185918-compute@developer.gserviceaccount.com. The service account used must be granted the 'Secret Manager Secret Accessor' role (roles/secretmanager.secretAccessor) at the secret, project or higher level.
│ spec.template.spec.containers[0].env[12].value_from.secret_key_ref.name: Permission denied on secret: projects/938038185918/secrets/LINE_CLIENT_SECRET/versions/latest for Revision service account 938038185918-compute@developer.gserviceaccount.com. The service account used must be granted the 'Secret Manager Secret Accessor' role (roles/secretmanager.secretAccessor) at the secret, project or higher level.
│ 
│   with google_cloud_run_v2_service.release,
│   on cloud-run.tf line 6, in resource "google_cloud_run_v2_service" "release":
│    6: resource "google_cloud_run_v2_service" "release" {
│ 
╵

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant