如何为 VPC 的 AWS EB 实例自动创建经典 Link
How to auto create a Classic Link for AWS EB Instances to VPC
我在 EB 上有一个 Classic 应用程序需要连接到 VPC 中的 RDS。
我可以通过进入 EC2 - 实例 - 操作 - 经典 Link - Link 到 VPC,手动配置 EB 实例以允许经典 Link 到 VPC。
一旦我这样做了,一切都很好,但是如果没有手动干预,这不会自动 link 新实例。
我知道我需要将 EB 应用移动到 VPC 中,但我想知道是否可以将 EB 设置为在 EB 中为新实例自动创建经典 Link?
我原以为我可以编辑 config/yml 文件来预配置新实例,但没有找到任何对此的引用。
有谁知道这是否可行,如果可行怎么办?
谢谢!
I was wondering if I could set EB to auto-create a Classic Link for new instances within EB
是 - 您可以使用 attach-classic-link-vpc
命令将 EC2-Classic 实例 link 连接到启用了 ClassicLink 的 VPC。有关每种语言的指南,请参阅 EB-CLI, PowerShell, or EC2API 参考文档。
如果您希望实例在创建时自动执行,我的建议是使用 EC2API。通过metadata calls查询并获取实例id和vpc id。然后在 EC2API 调用中使用这些 ID。
Does anyone know if this is possible and if so how to do it?
勾选example at the bottom of the EC2API attach-classic-link-vpc page or another example found at this site。后者让您首先通过身份和访问管理授予 运行 此命令的权限。
其他经典link api调用可以找到here以防您需要经典link启用您的VPC或执行其他常见经典link任务。
运行 尝试一下。如果您遇到困难,请创建一个新问题,其中包含确切的细节和尽可能多的 configuration/diagnostic 信息 post,我们可以尝试帮助您解决问题。
我能够使用此脚本完成此操作(在您的 EB 环境变量中设置 CLASSIC_LINK_GROUPS
,以便您可以更改每个环境使用的组):
# Enable ClassicLink on the new instance (so it can connect to VPC resources)
commands:
"Link to VPC":
command: >
aws ec2 attach-classic-link-vpc
--instance-id `wget -q -O - http://169.254.169.254/latest/meta-data/instance-id`
--vpc-id vpc-XXX
--groups `sudo /opt/elasticbeanstalk/bin/get-config environment -k CLASSIC_LINK_GROUPS`
--region us-west-2
在您的 .ebextensions
文件夹中将其另存为 00_classic_link.config
。
我在 EB 上有一个 Classic 应用程序需要连接到 VPC 中的 RDS。
我可以通过进入 EC2 - 实例 - 操作 - 经典 Link - Link 到 VPC,手动配置 EB 实例以允许经典 Link 到 VPC。 一旦我这样做了,一切都很好,但是如果没有手动干预,这不会自动 link 新实例。
我知道我需要将 EB 应用移动到 VPC 中,但我想知道是否可以将 EB 设置为在 EB 中为新实例自动创建经典 Link?
我原以为我可以编辑 config/yml 文件来预配置新实例,但没有找到任何对此的引用。
有谁知道这是否可行,如果可行怎么办?
谢谢!
I was wondering if I could set EB to auto-create a Classic Link for new instances within EB
是 - 您可以使用 attach-classic-link-vpc
命令将 EC2-Classic 实例 link 连接到启用了 ClassicLink 的 VPC。有关每种语言的指南,请参阅 EB-CLI, PowerShell, or EC2API 参考文档。
如果您希望实例在创建时自动执行,我的建议是使用 EC2API。通过metadata calls查询并获取实例id和vpc id。然后在 EC2API 调用中使用这些 ID。
Does anyone know if this is possible and if so how to do it?
勾选example at the bottom of the EC2API attach-classic-link-vpc page or another example found at this site。后者让您首先通过身份和访问管理授予 运行 此命令的权限。
其他经典link api调用可以找到here以防您需要经典link启用您的VPC或执行其他常见经典link任务。
运行 尝试一下。如果您遇到困难,请创建一个新问题,其中包含确切的细节和尽可能多的 configuration/diagnostic 信息 post,我们可以尝试帮助您解决问题。
我能够使用此脚本完成此操作(在您的 EB 环境变量中设置 CLASSIC_LINK_GROUPS
,以便您可以更改每个环境使用的组):
# Enable ClassicLink on the new instance (so it can connect to VPC resources)
commands:
"Link to VPC":
command: >
aws ec2 attach-classic-link-vpc
--instance-id `wget -q -O - http://169.254.169.254/latest/meta-data/instance-id`
--vpc-id vpc-XXX
--groups `sudo /opt/elasticbeanstalk/bin/get-config environment -k CLASSIC_LINK_GROUPS`
--region us-west-2
在您的 .ebextensions
文件夹中将其另存为 00_classic_link.config
。