(aws-cdk-lib): aws-sam.CfnApi does not support auth.ResourcePolicy and other options
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 74
Description
### Describe the bug
`AWS::Serverless::Api` supports various auth methods.
> [AddApiKeyRequiredToCorsPreflight](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-api-apiauth.html#sam-api-apiauth-addapikeyrequiredtocorspreflight): Boolean
> [AddDefaultAuthorizerToCorsPreflight](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-api-apiauth.html#sam-api-apiauth-adddefaultauthorizertocorspreflight): Boolean
> [ApiKeyRequired](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-api-apiauth.html#sam-api-apiauth-apikeyrequired): Boolean
> [Authorizers](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-api-apiauth.html#sam-api-apiauth-authorizers): [CognitoAuthorizer](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-api-cognitoauthorizer.html) | [LambdaTokenAuthorizer](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-api-lambdatokenauthorizer.html) | [LambdaRequestAuthorizer](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-api-lambdarequestauthorizer.html)
> [DefaultAuthorizer](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-api-apiauth.html#sam-api-apiauth-defaultauthorizer): String
> [InvokeRole](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-api-apiauth.html#sam-api-apiauth-invokerole): String
> [ResourcePolicy](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-api-apiauth.html#sam-api-apiauth-resourcepolicy): [ResourcePolicyStatement](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-api-resourcepolicystatement.html)
> [UsagePlan](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-api-apiauth.html#sam-api-apiauth-usageplan): [ApiUsagePlan](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-api-apiusageplan.html)
>
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-api-apiauth.html
However, only `AddDefaultAuthorizerToCorsPreflight`, `Authorizers`, and `DefaultAuthorizer` are supported.
Others such as `ResourcePolicy` and `ApiKeyRequired` are not supported.
./node_modules/aws-cdk-lib/aws-sam/lib/sam.generated.d.ts
```
export interface CfnApiProps {
[...]
/**
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-serverless-api.html#cfn-serverless-api-auth
*/
readonly auth?: CfnApi.AuthProperty | cdk.IResolvable;
```
```
interface AuthProperty {
/**
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-serverless-api-auth.html#cfn-serverless-api-auth-adddefaultauthorizertocorspreflight
*/
readonly addDefaultAuthorizerToCorsPreflight?: boolean | cdk.IResolvable;
/**
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-serverless-api-auth.html#cfn-serverless-api-auth-authorizers
*/
readonly authorizers?: any | cdk.IResolvable;
/**
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-serverless-api-auth.html#cfn-serverless-api-auth-defaultauthorizer
*/
readonly defaultAuthorizer?: string;
```
### Regression Issue
- [ ] Select this option if this issue appears to be a regression.
### Last Known Working CDK Version
_No response_
### Expected Behavior
It should cover all supported options.
### Current Behavior
only `AddDefaultAuthorizerToCorsPreflight`, `Authorizers`, and `DefaultAuthorizer` are supported.
### Reproduction Steps
See above
### Possible Solution
_No response_
### Additional Information/Context
_No response_
### CDK CLI Version
2.159.1 (build c66f4e3)
### Framework Version
_No response_
### Node.js Version
20
### OS
ubuntu
### Language
TypeScript
### Language Version
_No response_
### Other information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.