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

Fixing issue bind asg to space with non admin user #486

Closed
wants to merge 2 commits into from

Conversation

damzog
Copy link
Contributor

@damzog damzog commented Jun 2, 2023

#405

First of all let me say that the concept of moving the user attributes (developers, managers, ...) from the cf space resource to a separate cf space users resource has a major drawback: If you use a user for your terraforming that is not an admin (e.g. only org admin) this user needs to be assigned as space developer to the new space right after creation. Otherwise asgs can't be assigned.

Second in order to manage asgs for a space with a non admin user you can't use the path
/v2/security_groups/:asg_guid/spaces/:s_guid
-> Unauthorized
but you need to use
/v2/spaces/:s_guid/asgs/[staging_]security_groups/:asg_guid
-> works if your user is space developer for the space

So I changed the code accordingly. Now something like the following snippet works (gives a warning)

data "cloudfoundry_asg" "asg001" {
    name = "system_local_cf_api"
}
data "cloudfoundry_user" "user001" {
    name = "my-org-manager-who-can-create-spaces"
    org_id = data.cloudfoundry_org.org001.id   
}
resource "cloudfoundry_space" "space001" {
    name = "bhc-demo"
    org = data.cloudfoundry_org.org001.id
    asgs = [ data.cloudfoundry_asg.asg001.id ]
    staging_asgs = [ data.cloudfoundry_asg.asg001.id ]
    developers = [
      data.cloudfoundry_user.user001.id
   ]
}

@damzog damzog closed this Jun 3, 2023
@damzog
Copy link
Contributor Author

damzog commented Jun 3, 2023

I created an updated version which will implicitly make the terraform user space manager and space developer for tf managed space

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.

1 participant