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!: create security group outside the module #382

Merged
merged 1 commit into from
Jan 22, 2025
Merged

Conversation

kayman-mk
Copy link
Member

@kayman-mk kayman-mk commented Jan 21, 2025

Description

Roles are typically interconnected. So it is better to create the role outside the module and import its name.

Usually security groups are related to each other and it is better to create them outside a module in a central place. Therefor we no longer create the security group inside the module.

Migrations required

Create the security group and IAM role outside the module and pass the values.

resource "aws_security_group" "this" {
  vpc_id = module.vpc.vpc_id

  name        = "bastion-host"
  description = "Securing the bastion host"
}

resource "aws_iam_role" "access_bastion" {
  name        = "connect-bastion"
  description = "Role used to connect to the bastion instance."

  assume_role_policy = jsonencode({
    Version = "2012-10-17",
    Statement = [
      {
        Effect    = "Allow",
        Action    = "sts:AssumeRole",
        Principal = { "AWS" : module.bastion_user.iam_user_arn }
    }]
  })
}

module "bastion_host" {
  # other stuff here …
  connect_bastion_role_name = aws_iam_role.access_bastion.name

  security_group_id     = aws_security_group.this.id
}

Copy link
Contributor

Hey @kayman-mk! 👋

Thank you for your contribution to the project. Please refer to the
contribution rules for a quick overview of the process.

Make sure that this PR clearly explains:

  • the problem being solved
  • the best way a reviewer and you can test your changes

With submitting this PR you confirm that you hold the rights of the code added and agree that it will
published under this LICENSE.

The following ChatOps commands are supported:

  • /help: notifies a maintainer to help you out
  • /ready: marks the PR as ready for review and removes the checklist

Simply add a comment with the command in the first line. If you need to pass more information, separate it
with a blank line from the command.

This message was generated automatically. You are welcome to
improve it.

@kayman-mk kayman-mk force-pushed the kayma/security branch 2 times, most recently from 2db234a to d543e4b Compare January 21, 2025 21:31
Roles are typically interconnected. So it is better to create the role outside the module and import its name.

Usually security groups are related to each other and it is better to create them outside a module in a central place. Therefor we no longer create the security group inside the module.
@kayman-mk kayman-mk marked this pull request as ready for review January 21, 2025 21:38
@kayman-mk kayman-mk requested a review from a team as a code owner January 21, 2025 21:38
@kayman-mk kayman-mk requested review from FalkoSp and kindermannlennart and removed request for FalkoSp January 21, 2025 21:38
@kayman-mk kayman-mk merged commit 29e7e8d into main Jan 22, 2025
27 checks passed
@kayman-mk kayman-mk deleted the kayma/security branch January 22, 2025 06:40
@HapagLloydTechnicalUser
Copy link
Contributor

🎉 This PR is included in version 4.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants