Add IAM Permissions Boundary support for environments#1928
Conversation
e9f6db7 to
eee7891
Compare
|
|
||
| TagsUtil.add_tags(stack=self, model=Environment, target_type='environment') | ||
|
|
||
| if self._environment.PermissionsBoundaryPolicyArn: |
There was a problem hiding this comment.
So when user has entered nothing , then in that case this will be '' ? ( empty string ) . If yes, wouldn't this pass empty string ''.
The reason I am thinking it will be '' is because of the code here = backend/dataall/core/environment/services/environment_service.py .. The model uses PermissionsBoundaryPolicyArn=data.get('PermissionsBoundaryPolicyArn', ''),
Please correct if I am wrong here
There was a problem hiding this comment.
If the user pass an empty string '' the condition will evaluate to False and hence the boundary will be removed. Is that wrong?
There was a problem hiding this comment.
That is right. I actually wanted to allude to the possibility if the user enters ' ' ( blank space ) or 'arn:aws....' then in that case are we validating that the input is an ARN or that we are conditioning the string properly in the backend ?
There was a problem hiding this comment.
- Empty string will mean no boundary (it will be removed if already set)
- Invalid arn will mean an async deployment failure indeed, we could validate the ARN pattern as we do elsewhere if you prefer
There was a problem hiding this comment.
Invalid arn will mean an async deployment failure indeed, we could validate the ARN pattern as we do elsewhere if you prefer
Anything is fine . I think if the stack fails on deployment then the ARN can be corrected by editing it worsecase
TejasRGitHub
left a comment
There was a problem hiding this comment.
Added one comment. Rest all looks good
Deployment NotesWhen updating an existing environment with a
These must be added to the cfn-exec role policy for the permissions boundary feature to work. Without them, CloudFormation cannot attach or remove the boundary from IAM roles in the stack. Additionally, if the permissions boundary policy ARN referenced by the environment is deleted (e.g., by automated IAM cleanup processes), the stack will enter Tests Performed
|
It probably pass my tests because I don't use the custom template. I pushed a commit with the fix.
I am not sure how to help with that. Do you have a way to instruct your scanners to leave the policy alone if it is used? |
Hey @petrkalos , no need for any fix on that. Its just how I solved this issue when the stacks where in UPDATE_ROLLBACK_FAILED. |
TejasRGitHub
left a comment
There was a problem hiding this comment.
LGTM
All tests passed with the new permissions
Summary
Adds the ability to configure an IAM Permissions Boundary policy on data.all environments. When set, the boundary is automatically applied to all IAM roles created by the environment, dataset, and pipeline CDK stacks — including roles auto-generated by CDK constructs (e.g.
cr.Provider,BucketDeployment).This is a common requirement for organizations that enforce permissions boundaries as part of their AWS account governance.
Changes
Backend
input_types.py,types.py): AddedPermissionsBoundaryPolicyArnas an optional string field toNewEnvironmentInput,ModifyEnvironmentInput, and theEnvironmenttype.environment_models.py): Added nullablePermissionsBoundaryPolicyArncolumn to theEnvironmentmodel.environment_service.py): Handles the new field on create and update. On update, the field is set when the key is present in the input (including empty string to clear it).permissions_boundary_aspect.py): NewPermissionsBoundaryAspectclass that walks the construct tree and addsPermissionsBoundaryto everyAWS::IAM::Roleresource. Applied in:environment_stack.pydataset_stack.pydatapipelines_pipeline.pya4f8b2c1d3e5): Adds thePermissionsBoundaryPolicyArncolumn to theenvironmenttable.Migration fix
ba2da94739ab: Replaced ORMsession.query(Environment)andsession.query(DatasetBase)with raw SQL queries. The ORM model now includes the new column, which doesn't exist in the DB when this older migration runs — causing aProgrammingError. Using raw SQL with only the needed columns avoids this.Frontend
getEnvironment.js: AddedPermissionsBoundaryPolicyArnto the GraphQL query.EnvironmentCreateForm.js: Added optional text field in the Deployment card and included the value in the create mutation payload.EnvironmentEditForm.js: Added optional text field in the AWS Information card and included the value in the update mutation payload.EnvironmentConsoleAccess.js: Displays the boundary ARN in the AWS Information section on the environment details page (conditionally rendered when set).Integration tests
queries.py: AddedPermissionsBoundaryPolicyArnto theENV_TYPEfragment and as an optional parameter tocreate_environment.global_conftest.py: Passed the new parameter through thecreate_envcontext manager.session_env1now creates withPermissionsBoundaryPolicyArn='arn:aws:iam::aws:policy/AdministratorAccess'.test_environment.py: Addedtest_env_permissions_boundarywhich asserts the boundary ARN is returned by the API and verifies the environment's default IAM role in AWS has the boundary attached.How it works
Testing
PermissionsBoundaryproperty set after stack deploymentResolve #1233