Skip to content

Commit

Permalink
Merge pull request #8 from strongdm/role_grants
Browse files Browse the repository at this point in the history
Role_grants
  • Loading branch information
wrenhunter authored May 16, 2022
2 parents abff026 + 7cd07b9 commit f27f3a6
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 66 deletions.
18 changes: 0 additions & 18 deletions onboarding.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,6 @@ module "strongdm_onboarding" {
# If set to false the default VPC will be used instead
# create_vpc = true


# List of existing users to grant resources to
# NOTE: These emails must exactly match existing users in strongDM or an error will occur
# NOTE: An error will occur if these users are already assigned to a role in strongDM
grant_to_existing_users = [
var.SDM_ADMINS_EMAILS
]

# New accounts to create with access to all resources
admin_users = [
"[email protected]",
]

# New accounts to create with read-only permissions
read_only_users = [
"[email protected]",
]

# Tags will be added to strongDM and AWS resources.
# tags = {}
}
7 changes: 5 additions & 2 deletions onboarding/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ data "aws_vpc" "default" {
default = true
}

data "aws_subnet_ids" "subnets" {
data "aws_subnets" "subnets" {
count = var.create_vpc ? 0 : 1
vpc_id = data.aws_vpc.default[0].id
filter {
name = "vpc-id"
values = [data.aws_vpc.default[0].id]
}
}

# ---------------------------------------------------------------------------- #
Expand Down
6 changes: 0 additions & 6 deletions onboarding/eks_cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,6 @@ resource "sdm_resource" "k8s_eks_data_eks" {
}
}

resource "sdm_role_grant" "admin_grant_eks" {
count = var.create_eks ? 1 : 0
role_id = var.admins_id
resource_id = sdm_resource.k8s_eks_data_eks[0].id
}

module "configmap" {
count = var.create_eks ? 1 : 0
source = "./configmap"
Expand Down
14 changes: 1 addition & 13 deletions onboarding/http/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,7 @@ resource "sdm_resource" "web_page" {
tags = merge({ Name = "${var.prefix}-http" }, var.default_tags, var.tags)
}
}
resource "sdm_role_grant" "admin_grant_web_page" {
role_id = var.admins_id
resource_id = sdm_resource.web_page.id
}
resource "sdm_role_grant" "read_only_grant_web_page" {
role_id = var.read_only_id
resource_id = sdm_resource.web_page.id
}

# ---------------------------------------------------------------------------- #
# Access the EC2 instance with strongDM over SSH
# ---------------------------------------------------------------------------- #
Expand All @@ -101,8 +94,3 @@ resource "sdm_resource" "ssh_ec2" {
tags = merge({ Name = "${var.prefix}-http" }, var.default_tags, var.tags)
}
}
resource "sdm_role_grant" "admin_grant_ssh_ec2" {
count = var.create_ssh ? 1 : 0
role_id = var.admins_id
resource_id = sdm_resource.ssh_ec2[0].id
}
23 changes: 1 addition & 22 deletions onboarding/mysql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,8 @@ data "aws_ami" "ubuntu" {

filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"]
values = ["ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*"]
}

filter {
name = "virtualization-type"
values = ["hvm"]
}

}

resource "aws_security_group" "mysql" {
Expand Down Expand Up @@ -104,11 +98,6 @@ resource "sdm_resource" "mysql_admin" {
}
}

resource "sdm_role_grant" "admin_grant_mysql_admin" {
role_id = var.admins_id
resource_id = sdm_resource.mysql_admin.id
}

resource "sdm_resource" "mysql_ro" {
mysql {
name = "${var.prefix}-mysql-read-only"
Expand All @@ -122,11 +111,6 @@ resource "sdm_resource" "mysql_ro" {
}
}

resource "sdm_role_grant" "read_only_grant_mysql_ro" {
role_id = var.read_only_id
resource_id = sdm_resource.mysql_ro.id
}

# ---------------------------------------------------------------------------- #
# Access the EC2 instance with strongDM over SSH
# ---------------------------------------------------------------------------- #
Expand All @@ -143,8 +127,3 @@ resource "sdm_resource" "mysql_ssh" {
}
}

resource "sdm_role_grant" "admin_grant_mysql_ssh" {
count = var.create_ssh ? 1 : 0
role_id = var.admins_id
resource_id = sdm_resource.mysql_ssh[0].id
}
2 changes: 1 addition & 1 deletion onboarding/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ variable "read_only_users" {

locals {
vpc_id = var.create_vpc ? module.network[0].vpc_id : data.aws_vpc.default[0].id
subnet_ids = var.create_vpc ? module.network[0].public_subnets : sort(data.aws_subnet_ids.subnets[0].ids)
subnet_ids = var.create_vpc ? module.network[0].public_subnets : sort(data.aws_subnets.subnets[0].ids)
default_tags = { CreatedBy = "strongDM-Onboarding" }
}
4 changes: 0 additions & 4 deletions onboarding/windows_server/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,3 @@ resource "sdm_resource" "windows_server" {
}
}

resource "sdm_role_grant" "admin_grant_windows_server" {
role_id = var.admins_id
resource_id = sdm_resource.windows_server.id
}

0 comments on commit f27f3a6

Please sign in to comment.