在 Atlas VPC 和 Google Cloud Platform VPC 之间创建网络对等连接。
network peering create 命令会检查您为 Atlas 项目指定的区域中是否存在 VPC。 如果存在,此命令会在该 VPC 和您的 VPC 之间创建对等互连。如果 Atlas VPC 不存在,此命令会创建一个 VPC,并在该 VPC 与您的 VPC 之间创建连接。
To learn more about network peering connections, see https://www.mongodb.com/zh-cn/docs/atlas/security-vpc-peering/.
要使用此命令,您必须使用具有“项目所有者”角色的用户帐户、服务帐户或API密钥进行身份验证。
语法
atlas networking peering create gcp [options]
选项
名称 | 类型 | 必需 | 说明 |
|---|---|---|---|
--atlasCidrBlock | 字符串 | true | Atlas用于项目中创建的所有网络对等连接的 CIDR区块。仅当您还没有Atlas VPC时才需要此选项。要学习;了解更多信息,请参阅Atlas用户界面标签页,网址为:https://dochub.mongodb.org/core/peering-connection-atlas。 |
--gcpProjectId | 字符串 | false | 网络对等互连所在的 GCP 项目的唯一标识符。 |
-h,--help | false | gcp 帮助 | |
--network | 字符串 | false | Atlas 项目中的网络对等连接的唯一标识符。 |
-o, --output | 字符串 | false | 输出格式。 有效值为 json、json-path、go-template 或 go-template-file。 要查看完整输出,请使用 -o json 选项。 |
--projectId | 字符串 | false | 标识要使用的项目的十六进制字符串。 此选项会覆盖配置文件或环境变量中的设置。 |
--region | 字符串 | false | container所在的 Atlas 地区列表。 |
继承选项
名称 | 类型 | 必需 | 说明 |
|---|---|---|---|
-P, --profile | 字符串 | false | 要从您的配置文件中使用的配置文件的名称。要学习;了解Atlas CLI配置文件,请参阅 https://dochub.mongodb.org/core/atlas-cli-save-connection-settings. |
输出
如果命令成功,CLI 将返回类似于以下示例的输出。 括号中的值代表您的价值观。
Network peering connection '<Id>' created.
示例
# Create a network peering connection between the Atlas VPC in CIDR block 192.168.0.0/24 and your GCP VPC with the GCP project ID grandiose-branch-256701 in the network named cli-test: atlas networking peering create gcp --atlasCidrBlock 192.168.0.0/24 --gcpProjectId grandiose-branch-256701 --network cli-test --output json