This repository has been archived by the owner on Jun 18, 2024. It is now read-only.
forked from NASA-IMPACT/veda-backend
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync updates from upstream, add permissions boundary to created roles…
… if needed (#8) * Point README to veda-docs (NASA-IMPACT#171) * Upgrade titiler and titiler-pgstac * Fix br/gzip header test * Remove factory (it's included in new titiler-pgstac version) NASA-IMPACT#148 (comment) * Remove pin on cramjam * Load test data in container (actions not updated) * fix actions tests * adjust container strategy * actions connections fix * remove -it flag (it broke actions) * re-enable lint, propagate test changes to other actions * docker-compose -> docker compose * Fix template import * include private subnet config * fix subnet type * format changes * pub accessible default true * remove publicly accessible variable * Add sql connection and execution abstraction * Add sql logic to fix projection extension types * add script to delete null stac_extensions * Lint and move sql command scripts to support_scripts dir * Use pythonic naming conventions * pgstac readme change * docker compose pgstac version * pre-deploy action fix * RDS Proxy initial implementation * proxy secret + urlllib fix * use pgstac 0.7.9 * Update set environment * Add support for permissions boundary * use titiler custom JSONResponse to handle NaN values --------- Co-authored-by: Julia Signell <jsignell@gmail.com> Co-authored-by: ividito <isayah@developmentseed.org> Co-authored-by: smohiudd <saadiq@developmentseed.org> Co-authored-by: Saadiq Mohiuddin <34844565+smohiudd@users.noreply.github.com> Co-authored-by: Nathan Zimmerman <npzimmerman@gmail.com> Co-authored-by: Caden Helbling <caden.helbling@gmail.com> Co-authored-by: vincentsarago <vincent.sarago@gmail.com> Co-authored-by: Alexandra Kirk <alexandra@developmentseed.org>
- Loading branch information
1 parent
8fba985
commit 0631f1c
Showing
23 changed files
with
1,287 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
"""Class that applies permissions boundary to all the roles created within a Stack""" | ||
from typing import Union | ||
|
||
import jsii | ||
from aws_cdk import IAspect, aws_iam | ||
from constructs import IConstruct | ||
from jsii._reference_map import _refs | ||
from jsii._utils import Singleton | ||
|
||
|
||
@jsii.implements(IAspect) | ||
class PermissionBoundaryAspect: | ||
""" | ||
This aspect finds all aws_iam.Role objects in a node (ie. CDK stack) and sets permission boundary to the given ARN. | ||
""" | ||
|
||
def __init__(self, permission_boundary: Union[aws_iam.ManagedPolicy, str]) -> None: | ||
""" | ||
:param permission_boundary: Either aws_iam.ManagedPolicy object or managed policy's ARN string | ||
""" | ||
self.permission_boundary = permission_boundary | ||
|
||
def visit(self, construct_ref: IConstruct) -> None: | ||
""" | ||
construct_ref only contains a string reference to an object. To get the actual object, we need to resolve it using JSII mapping. | ||
:param construct_ref: ObjRef object with string reference to the actual object. | ||
:return: None | ||
""" | ||
if isinstance(construct_ref, jsii._kernel.ObjRef) and hasattr( | ||
construct_ref, "ref" | ||
): | ||
kernel = Singleton._instances[ | ||
jsii._kernel.Kernel | ||
] # The same object is available as: jsii.kernel | ||
resolve = _refs.resolve(kernel, construct_ref) | ||
else: | ||
resolve = construct_ref | ||
|
||
def _walk(obj): | ||
if isinstance(obj, aws_iam.Role): | ||
cfn_role = obj.node.find_child("Resource") | ||
policy_arn = ( | ||
self.permission_boundary | ||
if isinstance(self.permission_boundary, str) | ||
else self.permission_boundary.managed_policy_arn | ||
) | ||
cfn_role.add_property_override("PermissionsBoundary", policy_arn) | ||
else: | ||
if hasattr(obj, "permissions_node"): | ||
for c in obj.permissions_node.children: | ||
_walk(c) | ||
if hasattr(obj, "node") and obj.node.children: | ||
for c in obj.node.children: | ||
_walk(c) | ||
|
||
_walk(resolve) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.