AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-400542

Amitabh Ghosh's questions

Martin Hope
Amitabh Ghosh
Asked: 2020-08-31 07:04:17 +0800 CST

Terraform:将多个安全组附加到 EC2 实例

  • 0

如何在创建 EC2 时附加多个安全组?我已经模块化如下:

**networking/main.tf**
# Web Server Security Group
resource "aws_security_group" "web_sg" {
  name        = "web_sg"
  description = "This security group will control the private Web Servers"
  vpc_id      = aws_vpc.perf_vpc.id
  egress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = ["0.0.0.0/0"]
  }
}

# Load Balancer Security Group
resource "aws_security_group" "alb_sg" {
  name        = "alb_sg"
  description = " This secruity group is for Application Load Balancer"
  vpc_id      = aws_vpc.perf_vpc.id
  egress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = ["0.0.0.0/0"]
  }
}

resource "aws_security_group" "perf_pvt_sg" {
  name        = "perf_pvt_sg"
  description = "Aptean_Base-Perf_Pvt"
  vpc_id      = aws_vpc.perf_vpc.id
  depends_on  = [aws_security_group.bastion_sg]

  ingress {
    description = "kaspersky"
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = ["10.176.0.35/32"]
  }

  egress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = ["0.0.0.0/0"]
  }
}

**networking/outputs.tf**
output "perf_pvt_sg" {
  value = aws_security_group.perf_pvt_sg.id
}

output "web_sg" {
  value = aws_security_group.web_sg.id
}

output "alb_sg" {
  value = aws_security_group.alb_sg.id
}

**root/main.tf**
# Deploy Web Servers
module "web_servers" {
  source          = "./web_servers"
  keyname         = module.domain_controllers.key_name
  public_key_path = var.public_key_path
  web_count       = var.web_count
  web_inst_type   = var.web_inst_type
  pvtsubnets      = module.networking.private_subnets
  webserver_sg    = [
    module.networking.web_sg,
    module.networking.perf_pvt_sg,
    module.networking.alb_sg
  ]
}

一切都很好,并且按预期创建,并且 terraform 输出也显示了资源,但是所有 EC2 实例(在这种情况下,我只是指向 Web 服务器)都附加了默认安全组。我确实看到,创建了所有其他安全组虽然没有附加。我也尝试将 web_sg 切换为 id 和 name 属性:

web_sg          = [
        module.networking.web_sg.id,
        module.networking.perf_pvt_sg.id,
        module.networking.alb_sg.id
        ]

这会引发错误(*.id 和 *.name 的错误相同):

Error: Unsupported attribute

  on main.tf line 46, in module "web_servers":
  46:     module.networking.web_sg.name,
    |----------------
    | module.networking.web_sg is "sg-008001301c71877a9"
This value does not have any attributes.


Error: Unsupported attribute

  on main.tf line 47, in module "web_servers":
  47:     module.networking.perf_pvt_sg.name,
    |----------------
    | module.networking.perf_pvt_sg is "sg-0a50f754aceaae6cd"

This value does not have any attributes.


Error: Unsupported attribute

  on main.tf line 48, in module "web_servers":
  48:     module.networking.alb_sg.name
    |----------------
    | module.networking.alb_sg is "sg-05c898e0b6873c411"

This value does not have any attributes.

我究竟做错了什么?

AWS 控制台: 在此处输入图像描述

在此处输入图像描述

编辑1: web_servers/main.tf

#Web Server
resource "aws_instance" "web" {
  count         = var.web_count
  ami           = data.aws_ami.server_ami.id
  ebs_optimized = true
  instance_type = var.web_inst_type
  subnet_id     = element(var.pvtsubnets, count.index)
  credit_specification {
    cpu_credits = "standard"
  }
  root_block_device {
    volume_type = "gp2"
    volume_size = 80
    encrypted   = true
    kms_key_id  = "1d9ef127-cc8f-4dda-9bdf-abdad498ea6f"
  }
  ebs_block_device {
    device_name = "/dev/sdf"
    volume_type = "gp2"
    volume_size = 40
    encrypted   = true
    kms_key_id  = "1d9ef127-cc8f-4dda-9bdf-abdad498ea6f"
  }
  tags = {
    Name = "PerformanceWeb0${count.index + 1}"
  }
}

web_servers/variables.tf

variable "keyname" {}
variable "public_key_path" {}
variable "web_count" {}
variable "web_inst_type" {}
variable "pvtsubnets" {
  type = list(string)
}
variable "webserver_sg" {}
amazon-ec2 amazon-web-services terraform
  • 1 个回答
  • 3902 Views
Martin Hope
Amitabh Ghosh
Asked: 2020-01-11 05:48:03 +0800 CST

限制 Windows OU 管理的能力

  • 0

我们的组织最近对安全措施进行了更改,我有一个要求,想知道它是否可以实施。

因此,我们的团队(比如说 Jim、Tim、Johnny、Sonny 和 Mary)正在为客户(1、2、3、4、5、6、7)管理域。我们现在的做法是在该 OU 下创建用户并创建安全组,并通过安全组授予用户访问相应客户环境的权限。像这样的东西 在此处输入图像描述

随着更多客户的加入 (8,9,10),我们将创建此类安全组并添加所需的用户。我想要实现的是只有 Jim 和 Tim 可以管理 Cust 3 和 Cust 4 安全组 (SG),以便在这些 SG 中添加删除用户,同时保留修改 Cust 1、2、5、6、7 和创建/modifying Cust 8,9,10 SGs 等等。他们就像超级管理员(不知道这是否是 Windows AD 中的一个术语)。现在 Johnny、Sonny 和 Mary 将保留修改 Cust 1、2、5、6、7 的能力,并在需要时添加 Cust 8、9、10,但他们绝对无权修改 Cust 3 和 4。他们可能拥有最大的阅读/查看权限。

我们创建SG通常遵循的命名约定是[Cloud]-[Customer]-[Access]。是否可以通过创建某种角色或 GPO 来执行正则表达式模式搜索并限制所述资源来实现这一点。

目前我们所有人都是域管理员。我可能必须再创建一个容器,并将 Johnny、Sonny 和 Mary 作为其中的一部分,而 Jim 和 Tim 则被列为域管理员。Idk,只是想大声思考。

windows
  • 1 个回答
  • 39 Views
Martin Hope
Amitabh Ghosh
Asked: 2017-03-17 08:56:17 +0800 CST

关闭 eth0 后 EC2 死机

  • 0

由于我的愚蠢,我在 EC2 实例上执行了此操作:

ifconfig eth0 down

在此之后,我的实例变得无响应,并且我看不到启动 eth0 的方法。我无法通过 SSH 连接到实例,也无法更改 ENI(我从未在 VPC 中配置备用 ENI)。唯一可用的选项是终止实例。现在,我知道我可以将另一个 ENI 附加到实例 (eth1)。我想了解的是:

  1. 如果 eth0 关闭,实例是否仍然可以使用 eth1 运行或启动(考虑到实例在启动时使用了两个 eth*)?
  2. 考虑到它是辅助 ENI,eth1 是否会继续更改私有 IP?

希望我的问题有意义。

amazon-ec2
  • 1 个回答
  • 510 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve