将云服务 Google 更改为 AWS:创建防火墙的痛苦

问题描述 投票:0回答:1

我想在 AWS 中创建手动防火墙,但我今天是 Google Cloud 用户。 在我的 Ubuntu VM 中的 Google Cloud 中,我编码:

gcloud auth login
gcloud beta compute firewall-rules create allow-rstudio-server \
    --allow tcp:8787 \
    --target-tags rstudio-server
gcloud compute instances add-tags fc-cmpc-1 --tags rstudio-server

请问,对于 AWS 的相同代码有任何帮助吗?

提前致谢。

amazon-web-services cloud firewall
1个回答
0
投票

在 AWS 中,您可以创建手动防火墙(安全组)并将其与您的 EC2 实例关联。以下是使用 AWS CLI 命令的示例:

  1. 创建安全组:

    aws ec2 create-security-group --group-name allow-rstudio-server --description "Security group for RStudio Server"
    
  2. 授权入站流量:

    aws ec2 authorize-security-group-ingress --group-name allow-rstudio-server --protocol tcp --port 8787 --cidr 0.0.0.0/0
    

    此命令允许来自任何 IP 地址的端口 8787 上的传入 TCP 流量 (

    0.0.0.0/0
    )。根据您的具体需求调整 CIDR 块。

  3. 启动您的 EC2 实例并关联安全组: 使用 AWS 管理控制台或 CLI 启动 EC2 实例时,请确保将您创建的安全组 (

    allow-rstudio-server
    ) 与您的实例关联。

以下是使用 AWS CLI 启动实例的示例:

aws ec2 run-instances --image-id ami-xxxxxxxxxxxxxxxxx --instance-type t2.micro --key-name YourKeyPairName --security-groups allow-rstudio-server

ami-xxxxxxxxxxxxxxxxx
替换为适合您的实例的亚马逊系统映像 (AMI),并将
YourKeyPairName
替换为您的密钥对。

请记住将占位符值替换为您的具体详细信息。此外,请确保您已安装 AWS CLI 并配置了必要的凭证。

© www.soinside.com 2019 - 2024. All rights reserved.