Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.

feat(apps/infra): fixes Check AWS Access implementation#261

Merged
nxtcoder17 merged 1 commit into
release-v1.0.2from
fix/aws-cloudprovider-ready-check
Feb 8, 2024
Merged

feat(apps/infra): fixes Check AWS Access implementation#261
nxtcoder17 merged 1 commit into
release-v1.0.2from
fix/aws-cloudprovider-ready-check

Conversation

@nxtcoder17
Copy link
Copy Markdown
Member

@nxtcoder17 nxtcoder17 merged commit 05cf59d into release-v1.0.2 Feb 8, 2024
@nxtcoder17 nxtcoder17 deleted the fix/aws-cloudprovider-ready-check branch February 8, 2024 20:36
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

PR Type: Enhancement

PR Summary: This pull request introduces enhancements to the AWS access validation logic within the infrastructure domain. It extends the functionality of the validateAWSAssumeRole function by incorporating additional parameters for instance profile name and CloudFormation stack name, enabling more comprehensive validation checks. Additionally, it modifies a GraphQL configuration and removes an obsolete validator file, streamlining the project structure.

Decision: Comment

📝 Type: 'Enhancement' - not supported yet.
  • Sourcery currently only approves 'Typo fix' PRs.
✅ Issue addressed: this change correctly addresses the issue or implements the desired feature.
No details provided.
📝 Complexity: the changes are too large or complex for Sourcery to approve.
  • Files deleted: Sourcery does not currently approve diffs with deleted files.

General suggestions:

  • Consider parameterizing the AWS region or retrieving it from a configuration setting to enhance the function's adaptability to different deployment environments, rather than hardcoding it.
  • Review the error messaging for clarity and accuracy, especially in scenarios where AWS roles or CloudFormation stacks are not found, to ensure they accurately reflect the error state and facilitate debugging.
  • Evaluate the possibility of refactoring the validateAWSAssumeRole function to adhere to the single responsibility principle, potentially by separating the validation of the assume role and the CloudFormation stack into distinct functions.
  • Ensure that changes to configuration files, such as the provider name in the GraphQL configuration, are intentional and reflected across all dependent configurations and documentation to avoid potential integration issues.

Thanks for using Sourcery. We offer it for free for open source projects and would be very grateful if you could help us grow. If you like it, would you consider sharing Sourcery on your favourite social media? ✨

Share Sourcery

Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

func (d *domain) validateAWSAssumeRole(_ context.Context, paramExternalId string, roleARN string) error {
func (d *domain) validateAWSAssumeRole(_ context.Context, paramExternalId string, roleARN string, instanceProfileName string, cfStackName string) error {
sess, err := session.NewSession()
sess.Config.Region = aws.String("ap-south-1")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (llm): Hardcoding the AWS region to 'ap-south-1' may limit the flexibility of this function. Consider parameterizing the region or retrieving it from a configuration setting to enhance the function's adaptability to different deployment environments.


if resp.AssumedRoleUser.Arn != nil {
return nil
if resp.AssumedRoleUser == nil || resp.AssumedRoleUser.Arn == nil {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (llm): The error message for a missing AWS assume role does not specify whether the role or the ARN is missing. Providing a more detailed error message could help with debugging.

}
}

if !stackFound {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (llm): The error message 'waiting for cloudformation stack to be created' might be misleading as it suggests an action (waiting) rather than the actual error state (stack not found). Consider rephrasing to clearly indicate that the stack was not found.

}

if err := d.validateAWSAssumeRole(ctx, psecret.AWS.CfParamExternalID, psecret.AWS.GetAssumeRoleRoleARN()); err != nil {
if err := d.validateAWSAssumeRole(ctx, psecret.AWS.CfParamExternalID, psecret.AWS.GetAssumeRoleRoleARN(), psecret.AWS.CfParamInstanceProfileName, psecret.AWS.CfParamStackName); err != nil {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (llm): Adding parameters 'instanceProfileName' and 'cfStackName' to 'validateAWSAssumeRole' significantly increases the function's responsibilities. Consider refactoring to maintain single responsibility principle, possibly by splitting the validation of the assume role and the cloud formation stack into separate functions.

abdheshnayak pushed a commit that referenced this pull request Nov 5, 2024
feat(apps/infra): fixes Check AWS Access implementation
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[KLO-76] AWS Cloud Provider is showing valid even when Instance profile is not created

1 participant