我对如何将端点用于SSM感到非常困惑,以便隔离子网上的Lambda可以使用ssm.GetParameter
根据此问题,我需要一个SPC的VPC端点。我尝试这样做:
// Create a security group:
this.vpcsg = new ec2.SecurityGroup(this, 'vpc-sg', {
vpc: this.vpc,
allowAllOutbound: false,
securityGroupName: 'VPCSecurityGroup'
})
// endpoint creation
this.vpcEndpointSSM = new ec2.InterfaceVpcEndpoint(this, `SSMVpcEndpoint`, {
service: ec2.InterfaceVpcEndpointAwsService.SSM,
vpc: this.vpc,
subnets: { subnetType: ec2.SubnetType.ISOLATED },
securityGroups: [this.ingressSecurityGroup]
})
// And then later I call...
this.lambdaGQLAPI = new lambda.Function(this, `LambdaAPI`, {
code: new lambda.AssetCode(lambdaNodePath),
vpc: this.vpc,
vpcSubnets: { subnetType: ec2.SubnetType.ISOLATED },
functionName: this.functions.api,
handler: 'lambda_graphql.handler',
memorySize: 256,
timeout: core.Duration.minutes(2),
runtime: lambda.Runtime.NODEJS_12_X,
securityGroups: [props.dbSecurityGroup, this.vpcsg],
})
我还确保了lambda函数应该能够使用策略模拟器访问SSM,并且可以签出
但是我的功能只是尝试访问SSM超时。
安全组将分别应用于每个资源。安全组不同于子网。资源不驻留在“内部”安全组中。
除非安全组中存在允许其自身访问的特定规则,否则同一安全组中的资源无法相互通信。
例如,安全组可以具有一个允许入站端口80的规则,而源是同一安全组。这意味着具有该安全组的资源可以从与同一安全组关联的其他资源接收流量。
但是,通常最好定义两个安全组:
Lambda-SG
)上的一个安全组,该安全组允许所有出站访问Endpoint-SG
)上的一个安全组,该安全组允许来自Lambda-SG
也就是说,Endpoint-SG
专门指Lambda-SG
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句