找不到 AWS CDK C# 命名空间 IngressProperty

AWS CDK C# Namespace could not be found IngressProperty

我只是从这里“https://docs.aws.amazon.com/cdk/api/v1/dotnet/api/Amazon.CDK.AWS.EC2.CfnSecurityGroup.html”直接复制了 AWS CDK Docs 提供的示例。 11=]

但是当我尝试合成/部署时出现此错误

错误 CS0246:找不到类型或命名空间名称 'IngressProperty'(是否缺少 using 指令或程序集引用?

文档本身似乎不可靠或无法正常工作。

using Amazon.CDK;
using Constructs;
using Amazon.CDK.AWS.EC2;

namespace Sg
{
    public class SgStack : Stack
    {
        internal SgStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
        {
            var cfnSecurityGroup = new CfnSecurityGroup(this, "MyCfnSecurityGroup", new CfnSecurityGroupProps {
                GroupDescription = "test",

                GroupName = "test",
                SecurityGroupIngress = new [] { new IngressProperty  {
                    IpProtocol = "tcp",
                    CidrIp = "0.0.0.0/0",
                    Description = "description",
                    FromPort = 22,
                    ToPort = 22
                } },
                VpcId = "vpc-12345"
            });
        }
    }
}

IngressPropertyCfnSecurityGroup class 的一部分,因此要使其正常工作,您必须像这样更改代码:

var cfnSecurityGroup = new CfnSecurityGroup(this, "MyCfnSecurityGroup", new
    CfnSecurityGroupProps
{
    GroupDescription = "test",
    GroupName = "test",
    SecurityGroupIngress = new[] {

            // The change
            new CfnSecurityGroup.IngressProperty  {

            IpProtocol = "tcp",
            CidrIp = "0.0.0.0/0",
            Description = "description",
            FromPort = 22,
            ToPort = 22
        } 
    },
    VpcId = "vpc-12345"
});

或添加using static Amazon.CDK.AWS.EC2.CfnSecurityGroup;