PrefixList: FromPrefixListId method gives CS1061 error
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
When trying to use the FromPrefixListId method described in CDK .NET Reference (https://docs.aws.amazon.com/cdk/api/v2/dotnet/api/Amazon.CDK.AWS.EC2.PrefixList.html) to look up the prefix list by id, you get a CS1061 error.
Severity
Error
Code
CS1061
Description
'IPrefixList' does not contain a definition for 'FromPrefixListId' and no accessible extension method 'FromPrefixListId' accepting a first argument of type 'IPrefixList' could be found (are you missing a using directive or an assembly reference?)
### Expected Behavior
Return the PrefixList Id
### Current Behavior
Get a CS1061 Error
### Reproduction Steps
public AwsManagedPrefixList(Construct scope, string id, AwsManagedPrefixListProps props) : base(scope, id)
{
var prefixListId = new AwsCustomResource(this, "GetPrefixListId", new AwsCustomResourceProps
{
OnCreate = new AwsSdkCall
{
Service = "@aws-sdk/client-ec2",
Action = "DescribeManagedPrefixListsCommand",
Parameters = new Dictionary
{
{ "prefix-list-name", props.Name }
},
PhysicalResourceId = PhysicalResourceId.Of("${id}-${this.node.addr.slice(0, 16)}")
},
Policy = AwsCustomResourcePolicy.FromStatements( new[]
{
PolicyStatement.FromJson(
new Dictionary {
{ "Effect", "Allow" },
{ "Action", "ec2:DescribeManagedPrefixLists" },
{ "Resource", "*" }
}
),
})
}).GetResponseField("PrefixLists.0.PrefixListId");
this.PrefixList = PrefixList.FromPrefixListId(this, "PrefixList", prefixListId);
}
### Possible Solution
_No response_
### Additional Information/Context
_No response_
### CDK CLI Version
2.110.0 (build c6471f2)
### Framework Version
_No response_
### Node.js Version
v18.16.0
### OS
Windows 11
### Language
.NET
### Language Version
6.0.417
### Other information
Trying duplicate the workaround for https://github.com/aws/aws-cdk/issues/15115
This appears similar to the issue https://github.com/aws/aws-cdk/issues/28076
I looked up the implementation in library and got this
```
//
// Summary:
// Look up prefix list by id.
[JsiiMethod("fromPrefixListId", "{\"type\":{\"fqn\":\"aws-cdk-lib.aws_ec2.IPrefixList\"}}", "[{\"name\":\"scope\",\"type\":{\"fqn\":\"constructs.Construct\"}},{\"name\":\"id\",\"type\":{\"primitive\":\"string\"}},{\"name\":\"prefixListId\",\"type\":{\"primitive\":\"string\"}}]", false, false)]
public static IPrefixList FromPrefixListId(Construct scope, string id, string prefixListId)
{
return DeputyBase.InvokeStaticMethod(typeof(PrefixList), new Type[3]
{
typeof(Construct),
typeof(string),
typeof(string)
}, new object[3] { scope, id, prefixListId }, "FromPrefixListId");
}
}
```
Contributor guide
Research direction
Start with the PrefixList.FromPrefixListId call and the generated IPrefixList declaration shown in the issue. Compare the CDK .NET reference with the reproduction using version 2.110.0, then verify that the call compiles without CS1061 and returns the prefix list ID.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, csharp
- Domain
- cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100