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

cloud connectors role chaining #2960

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

moukoublen
Copy link
Member

@moukoublen moukoublen commented Jan 29, 2025

Summary of your changes

Screenshot/Data

Related Issues

Fixes: #2556

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary README/documentation (if appropriate)

Introducing a new rule?

@elastic elastic deleted a comment from mergify bot Jan 29, 2025
@moukoublen moukoublen force-pushed the cloud_connectors_chaining branch from 34d5f72 to e52824d Compare January 30, 2025 11:25
@moukoublen moukoublen marked this pull request as ready for review January 30, 2025 13:00
@moukoublen moukoublen requested a review from a team as a code owner January 30, 2025 13:00
@moukoublen moukoublen force-pushed the cloud_connectors_chaining branch from 540de53 to 54ed5af Compare February 3, 2025 10:36
@moukoublen moukoublen force-pushed the cloud_connectors_chaining branch from 54ed5af to a3154bf Compare February 11, 2025 08:04
func InitializeAWSConfigCloudConnectors(ctx context.Context, cfg config.AwsConfig) (*aws.Config, error) {
// 1. Load initial config
// (TODO: check directly assuming the first role in chain and/or libbeataws.InitializeAWSConfig(cfg))
// (TODO: consider os.Setenv("AWS_EC2_METADATA_DISABLED", "true"))
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure what to consider, to set it or to check the behavior when it was previously set?
Also, in MKI we block the IMDS ip address, how it affect the flow?

Copy link
Member Author

@moukoublen moukoublen Feb 12, 2025

Choose a reason for hiding this comment

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

The comment was for me (I will remove them) to check if we need to use the AWS_EC2_METADATA_DISABLED in case we needed to remove the firewall rules. We don't (we checked the flow with @amirbenun a while ago), so it's all good.

No changes needed. I will remove both TODOs.


const defaultDuration = 5 * time.Minute

// Chain Part 1 - Elastic Super Role Local
Copy link
Contributor

@olegsu olegsu Feb 11, 2025

Choose a reason for hiding this comment

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

Super role is misleading term, indicate that the role permissions are elevated when it only should be allowed to assume the global role

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe this is something to discuss in RFC level, wdyt?

)
localSuperRoleCredentialsCache := aws.NewCredentialsCache(localSuperRoleProvider)

// Chain Part 2 - Elastic Super Role Global
Copy link
Contributor

Choose a reason for hiding this comment

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

Super role is misleading term, indicate that the role permissions are elevated when we need only audit (SecurityAudit built-in AWS)

Copy link
Member Author

Choose a reason for hiding this comment

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

The global super role has not the audit policy, it has no policy part from the "assume anything". Feel free to refer RFC regarding the terminology.

)
globalSuperRoleCredentialsCache := aws.NewCredentialsCache(globalSuperRoleProvider)

// Chain Part 3 - Elastic Super Role Local
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Chain Part 3 - Elastic Super Role Local
// Chain Part 3 - Elastic Remote SecurityAudit

return fmt.Sprintf("%s-%s", resourceID, externalIDPart)
}

func InitializeAWSConfigCloudConnectors(ctx context.Context, cfg config.AwsConfig) (*aws.Config, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we better to have a more generic flow in case we need longer chain.
The chain can be part of the agent policy and be used also for non cloud connector use cases

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought about implementing it in a "loop" mode, but:

  1. this will eventually be moved to libbeat so a more generic approach can be implemented there
  2. After some tests that I just completed, there are even fewer steps now; it's the init and 2 extras assume instead of 3.

I believe a more generic approach (if it is worth the effort) can be implemented when that code gets transferred to libbeat.

Wdyt?

@moukoublen moukoublen force-pushed the cloud_connectors_chaining branch 2 times, most recently from bcc19af to 5c25106 Compare February 12, 2025 15:40
@moukoublen moukoublen force-pushed the cloud_connectors_chaining branch from 5c25106 to 3aaf8c5 Compare February 12, 2025 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Cloud Connectors] Configuration and Flow
3 participants