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: add role to only ssh to bastion #27

Merged
merged 1 commit into from
Mar 4, 2022
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
2 changes: 1 addition & 1 deletion ci/tasks/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ EOF
function write_users() {
echo ${TESTFLIGHT_ADMINS} | \
jq --arg sa "$(cat ${CI_ROOT}/gcloud-creds.json | jq -r '.client_email')" \
'{ users: [ .[] | { id: ., inception: true, platform: true, logs: true }, { id: "serviceAccount:\($sa)", inception: true, platform: true, logs: true } ]}' > inception/users.auto.tfvars.json
'{ users: [ .[] | { id: ., inception: true, platform: true, logs: true, bastion: true }, { id: "serviceAccount:\($sa)", inception: true, platform: true, logs: true, bastion: true } ]}' > inception/users.auto.tfvars.json
}

function cleanup_inception_key() {
Expand Down
1 change: 1 addition & 0 deletions examples/gcp/inception/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ variable "inception_sa" {}
variable "users" {
type = list(object({
id = string
bastion = bool
inception = bool
platform = bool
logs = bool
Expand Down
4 changes: 2 additions & 2 deletions modules/inception/gcp/bastion.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ resource "google_compute_instance" "bastion" {
data "google_iam_policy" "bastion" {
binding {
role = "roles/compute.osLogin"
members = local.platform_admins
members = local.bastion_users
}
binding {
role = "roles/compute.viewer"
members = local.platform_admins
members = local.bastion_users
}
binding {
role = "roles/compute.admin"
Expand Down
2 changes: 2 additions & 0 deletions modules/inception/gcp/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ variable "buckets_location" {}
variable "users" {
type = list(object({
id = string
bastion = bool
inception = bool
platform = bool
logs = bool
Expand All @@ -41,6 +42,7 @@ locals {
log_viewers = [for user in var.users : user.id if user.logs]
inception_admins = [for user in var.users : user.id if user.inception]
platform_admins = concat([for user in var.users : user.id if user.platform], ["serviceAccount:${var.inception_sa}"])
bastion_users = toset(concat([for user in var.users : user.id if user.bastion], platform_admins))

region = var.region
network_prefix = var.network_prefix
Expand Down