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

feat: add paths #787

Merged
merged 13 commits into from
Feb 10, 2025
Merged

feat: add paths #787

merged 13 commits into from
Feb 10, 2025

Conversation

kukushking
Copy link
Contributor

@kukushking kukushking commented Feb 5, 2025

Issue #, if available: #757

Description of changes:

  • add role_prefix and policy_prefix CLI args
  • add role_prefix and policy_prefix to deployment manifest / target account mappings
  • refactor to use roles with paths
  • use role arn for serviceRoleOverride
  • test cases with a new manifest
  • pass prefixes and permissions boundary to codeseeder
  • add to prefixes to region mapping
  • docs

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@kukushking kukushking self-assigned this Feb 5, 2025
@@ -206,7 +206,7 @@ def deploy_module(mdo: ModuleDeployObject) -> ModuleDeploymentResponse:
+ store_sf_bundle,
extra_env_vars=env_vars,
codebuild_compute_type=module_manifest.deploy_spec.build_type,
codebuild_role_name=mdo.module_role_name,
codebuild_role_name=mdo.module_role_arn,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the change implemented so that the role path is included?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. Path is part of the ARN. This feeds into CodeBuild's StartBuild API, serviceRoleOverride.

policy = yaml.safe_load(f)

if policy_prefix:
policy["Resources"]["ProjectPolicy"]["Properties"]["Path"] = policy_prefix
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is similar to bootstrap template overrides, for example here. I could introduce jinja instead but this is an overkill for one parameter override imo.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

@@ -54,23 +54,23 @@ Resources:
- logs:GetLogGroupFields
- logs:GetQueryResults
Resource:
- !Sub "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/codebuild/codeseeder-${ProjectName}*"
- Fn::Sub: "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/codebuild/codeseeder-${ProjectName}*"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why these changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fn::Sub is consistent with our bootstrap templates and can be processed by any yaml parser. Just to not have to bring cfn-flip as a dependency.

Copy link
Contributor

@dgraeber dgraeber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of docs to update ;)

@kukushking kukushking marked this pull request as ready for review February 6, 2025 14:21
"security_group_ids": security_group_ids,
}

if version.parse(cs.__version__) >= version.parse("1.3.0"):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to cut a codeseeder release and then will be able to remove this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does codeseeder 1.3.0 already support this? Why not just bump the minimum version of code-seeder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We just didn't cut 1.3.0 yet and I wanted to make this runnable with older versions until then

@kukushking kukushking requested a review from a team February 6, 2025 20:17
dgraeber
dgraeber previously approved these changes Feb 7, 2025
Comment on lines 67 to 73
@click.option(
"--role-prefix",
default="/",
help="""An IAM path prefix to use with the seedfarmer roles.
Use only if bootstrapped with this path""",
required=False,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes for apply, destroy, synth seem undocumented?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On it

Comment on lines +28 to +29
- Fn::Sub: "arn:${AWS::Partition}:iam::*:role/seedfarmer-{{ project_name }}*"
- Fn::Sub: "arn:${AWS::Partition}:iam::*:role/*/seedfarmer-{{ project_name }}*"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make more sense to use the prefix here for least privilege?

Suggested change
- Fn::Sub: "arn:${AWS::Partition}:iam::*:role/seedfarmer-{{ project_name }}*"
- Fn::Sub: "arn:${AWS::Partition}:iam::*:role/*/seedfarmer-{{ project_name }}*"
- Fn::Sub: "arn:${AWS::Partition}:iam::*:role{{ role_prefix }}seedfarmer-{{ project_name }}*"

Same goes for deployment_role.template.

Copy link
Contributor Author

@kukushking kukushking Feb 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I've started with but prefixes used with toolchain, deployment, and module deployment roles can be different (with the current design).

We can set it to one specific prefix here but that would essentially mean all prefixes must be the same across all roles (and more importantly all accounts, that may be owned by different teams with different requirements / SCP)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might make sense to leave a comment or something to that?

dgraeber
dgraeber previously approved these changes Feb 10, 2025
clokep
clokep previously approved these changes Feb 10, 2025
@kukushking kukushking dismissed stale reviews from clokep and dgraeber via 53d259b February 10, 2025 17:44
@dgraeber dgraeber requested review from clokep and dgraeber February 10, 2025 17:47
@dgraeber dgraeber merged commit 459ed0c into awslabs:main Feb 10, 2025
6 checks passed
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.

3 participants