-
Notifications
You must be signed in to change notification settings - Fork 87
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
Creating a space with asgs
specified fails
#405
Comments
Still present as of |
Noting here that for a similar previous issue (OrgManagers and SpaceManagers couldn't set user roles), there was a PR that fixed the problem by falling back to a slower check using available perms when the admin permission isn't present. Something like that is probably needed here as well. |
Hi @mogul, So I guess the onyl way out is the introduces a separate resource cloudfoundry_space_asgs |
That makes sense, considering that if you're using the CLI, you're able to manipulate ASGs separate from the act of creating a space. See also my issue about managing bindings separate from app creation. ;) |
Actually I found a way which might not look so nice at first but I think it makes sense to actually add the user used by tf as developer or manager to a newly created space, see my pull request. I guess you can still use the cf_space_users resource for all other users if you want. If you insist you could rename the space attribute developers to tf-user or similar. |
This actually matches the behavior of the CLI:
|
(So I think it should actually be implicit!) |
@mogul Ok. I have changed my implementation. Would be great if you can have a look and merge it. Do you want to create a bugfix branch? |
I would but I'm not a maintainer! @ArthurHlt or @loafoe can you help? |
There is one disputable aspect of the current implementation: The terraform user (tf-id) is added at create time. If (and only if) you add the same tf-id as part of the cf-space-user resource the create will work but on destroy once the f-space-user resource is destroyed any subsequent destroy of other space resources will fail. Unfortunately I have no easy fix for this. You could authorize the tf-id explicitly in every space related resource at least at destroy time. I do not like this so I kept this simple implementation that requires the tf-id left out of the cf-space-user config. |
I think that is reasonable behavior; people can just use |
@loafoe I have corrected the spelling error. |
Hi @loafoe, not sure if you have seen my comment on the pull request. So I repeat it here: Regarding the permadiff : Default behaviour of the space_users resource is to ignore users outside the configured users. You can override this with the force flag, see also code . So there will be no permadiff. Also be aware that a space and space-users resource can be managed in one "tf script" only. Others would need to refer to it as data. Regarding "a better fix would be to ensure the session user has sufficient permissions": Well the cf authorization model is rather simple. The authorization required for binding a sec-group to a space is space-developer or platform admin. However as platform operator I do not hand out platform admin privileges to my users. So this not an option. By the way this might need to be added to the testing strategy: In the README you suggest to test with an admin user in a pcf-dev environment. You should also test with an org manager only because that is the max privilige we will hand out to platform users. Generally I think the root cause of the issue is the fact that space user management has been detached from the space resource to the space-users resource. Hence there is no way of authorizing the session user on a newly created space. It can be fixed by detaching all relations of a space into separate objects (actually there are only two asgs and isolation segments). Then one would need to make sure that the space-user resource is created first be making the other object depending on it. Regarding "I also haven't seen this mechanism being used anywhere else in the provider": I just checked: The only resource where this could happen is the org itself. However the org has no attribute that requires a second api call after creation of the org itself. Hence the problem is not there. |
Anyway this is clearly a bug. If you do not like the fix I provided than please state how this bug shall be fixed. For me it is a essential that an org manager can create spaces and assign asgs to it. |
@ArthurHlt or @loafoe any update? |
Actually I have created now another fix by introducing a separate resource space_asgs similar to the existing space_users. It works fine but I have trouble to create and run unit tests because I do not have pcf-dev or similar. Will try with bbl on gcp but this might take a while. |
Same here... It's hard to contribute without a "spare" Cloud Foundry hanging around where we can run the tests! (I investigated using Korifi, which is pretty easy to set up locally, but haven't gotten to the point of actually running any tests yet.) |
@damzog thanks for staying on top of this. I saw your comments but was just swamped with other stuff last couple of days. Same as @mogul I don't have full access to a Cloud Foundry instance to test certain conditions. It's probably testament to how involved it is to set up a fully functional CF instance these days. I'll do a quick review and probably just merge your proposed solution as I don't see any other solution. |
@loafoe Now it is done. I have filed #498 which should ultimately solve the issue. I have tested the provider with my current setup. Also I created a test case which I ran selectively against our development environment with success. I was not able to run all tests because of general constraints (users could not be created because of weak passwords making most test cases fail). But as the change is completely additive I think that is acceptable. |
@loafoe any updates? |
@loafoe sorry to keep pinging... Is there anyone else who could merge this? |
Great, thanks so much! |
Hey @loafoe are you back from holiday yet? If not, can you let us know how long you'll be out? If so, can you let us know when this might get merged into a release? |
Hi, I actually cut a release yesterday which should include this change. |
Oh I missed that... Thanks so much! I'll give this a try today. |
I'm trying to create a space with an existing running security group, but I'm getting an authorization error even though the user running the terraform is an OrgManager.
I'm using cloudfoundry provider version 0.15.3.
The relevant terraform code:
The output:
Creating the same space without
asgs
specified works fine, and then callingcf bind-security-group
for that space also works.The text was updated successfully, but these errors were encountered: