Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding new appsync props #3423

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions samtranslator/internal/model/appsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class GraphQLApi(Resource):
"OpenIDConnectConfig": GeneratedProperty(),
"UserPoolConfig": GeneratedProperty(),
"AdditionalAuthenticationProviders": GeneratedProperty(),
"Visibility": GeneratedProperty(),
"OwnerContact": GeneratedProperty(),
}

Name: str
Expand All @@ -124,6 +126,8 @@ class GraphQLApi(Resource):
Tags: Optional[List[Dict[str, Any]]]
XrayEnabled: Optional[bool]
LogConfig: Optional[LogConfigType]
Visibility: Optional[str]
OwnerContact: Optional[str]

runtime_attrs = {"api_id": lambda self: fnGetAtt(self.logical_id, "ApiId")}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ class Properties(BaseModel):
ApiKeys: Optional[Dict[str, ApiKey]]
DomainName: Optional[DomainName]
Cache: Optional[Cache]
Visibility: Optional[PassThroughProp]
OwnerContact: Optional[PassThroughProp]


class Resource(BaseModel):
Expand Down
11 changes: 11 additions & 0 deletions samtranslator/model/sam_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -2215,6 +2215,8 @@ class SamGraphQLApi(SamResourceMacro):
"ApiKeys": Property(False, IS_DICT),
"DomainName": Property(False, IS_DICT),
"Cache": Property(False, IS_DICT),
"Visibility": PassThroughProperty(False),
"OwnerContact": PassThroughProperty(False),
}

Auth: List[Dict[str, Any]]
Expand All @@ -2230,6 +2232,8 @@ class SamGraphQLApi(SamResourceMacro):
ApiKeys: Optional[Dict[str, Dict[str, Any]]]
DomainName: Optional[Dict[str, Any]]
Cache: Optional[Dict[str, Any]]
Visibility: Optional[PassThrough]
OwnerContact: Optional[PassThrough]

# stop validation so we can use class variables for tracking state
validate_setattr = False
Expand Down Expand Up @@ -2300,6 +2304,13 @@ def _construct_appsync_api_resources(
api = GraphQLApi(logical_id=self.logical_id, depends_on=self.depends_on, attributes=self.resource_attributes)

api.Name = passthrough_value(model.Name) or self.logical_id
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-graphqlapi.html#cfn-appsync-graphqlapi-visibility
# WARNING: If Visibility has not been defined, explicitly setting it to GLOBAL in a template/stack update will result in an API replacement and new DNS values.
# we don't want to force client's API re-creation
if model.Visibility:
api.Visibility = passthrough_value(model.Visibility)
if model.OwnerContact:
api.OwnerContact = passthrough_value(model.OwnerContact)
api.XrayEnabled = model.XrayEnabled

lambda_auth_arns = self._parse_and_set_auth_properties(api, model.Auth)
Expand Down
90 changes: 37 additions & 53 deletions samtranslator/schema/schema.json

Large diffs are not rendered by default.

84 changes: 37 additions & 47 deletions schema_source/cloudformation-docs.json

Large diffs are not rendered by default.

84 changes: 31 additions & 53 deletions schema_source/cloudformation.schema.json

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions schema_source/sam.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6649,6 +6649,9 @@
"Name": {
"$ref": "#/definitions/PassThroughProp"
},
"OwnerContact": {
"$ref": "#/definitions/PassThroughProp"
},
"Resolvers": {
"additionalProperties": {
"additionalProperties": {
Expand All @@ -6669,6 +6672,9 @@
"title": "Tags",
"type": "object"
},
"Visibility": {
"$ref": "#/definitions/PassThroughProp"
},
"XrayEnabled": {
"title": "Xrayenabled",
"type": "boolean"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Transform: AWS::Serverless-2016-10-31
Resources:
SuperCoolAPI:
Type: AWS::Serverless::GraphQLApi
Properties:
SchemaInline: |
type Mutation {
addTodo(id: ID!, name: String, description: String, priority: Int): Todo
}
Visibility: PRIVATE
OwnerContact: blah-blah
Auth:
Type: AWS_IAM
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"Resources": {
"SuperCoolAPI": {
"Properties": {
"AuthenticationType": "AWS_IAM",
"LogConfig": {
"CloudWatchLogsRoleArn": {
"Fn::GetAtt": [
"SuperCoolAPICloudWatchRole",
"Arn"
]
},
"FieldLogLevel": "ALL"
},
"Name": "SuperCoolAPI",
"OwnerContact": "blah-blah",
"Tags": [
{
"Key": "graphqlapi:createdBy",
"Value": "SAM"
}
],
"Visibility": "PRIVATE"
},
"Type": "AWS::AppSync::GraphQLApi"
},
"SuperCoolAPICloudWatchRole": {
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": [
"sts:AssumeRole"
],
"Effect": "Allow",
"Principal": {
"Service": [
"appsync.amazonaws.com"
]
}
}
],
"Version": "2012-10-17"
},
"ManagedPolicyArns": [
{
"Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSAppSyncPushToCloudWatchLogs"
}
]
},
"Type": "AWS::IAM::Role"
},
"SuperCoolAPISchema": {
"Properties": {
"ApiId": {
"Fn::GetAtt": [
"SuperCoolAPI",
"ApiId"
]
},
"Definition": "type Mutation {\n addTodo(id: ID!, name: String, description: String, priority: Int): Todo\n}\n"
},
"Type": "AWS::AppSync::GraphQLSchema"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"Resources": {
"SuperCoolAPI": {
"Properties": {
"AuthenticationType": "AWS_IAM",
"LogConfig": {
"CloudWatchLogsRoleArn": {
"Fn::GetAtt": [
"SuperCoolAPICloudWatchRole",
"Arn"
]
},
"FieldLogLevel": "ALL"
},
"Name": "SuperCoolAPI",
"OwnerContact": "blah-blah",
"Tags": [
{
"Key": "graphqlapi:createdBy",
"Value": "SAM"
}
],
"Visibility": "PRIVATE"
},
"Type": "AWS::AppSync::GraphQLApi"
},
"SuperCoolAPICloudWatchRole": {
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": [
"sts:AssumeRole"
],
"Effect": "Allow",
"Principal": {
"Service": [
"appsync.amazonaws.com"
]
}
}
],
"Version": "2012-10-17"
},
"ManagedPolicyArns": [
{
"Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSAppSyncPushToCloudWatchLogs"
}
]
},
"Type": "AWS::IAM::Role"
},
"SuperCoolAPISchema": {
"Properties": {
"ApiId": {
"Fn::GetAtt": [
"SuperCoolAPI",
"ApiId"
]
},
"Definition": "type Mutation {\n addTodo(id: ID!, name: String, description: String, priority: Int): Todo\n}\n"
},
"Type": "AWS::AppSync::GraphQLSchema"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"Resources": {
"SuperCoolAPI": {
"Properties": {
"AuthenticationType": "AWS_IAM",
"LogConfig": {
"CloudWatchLogsRoleArn": {
"Fn::GetAtt": [
"SuperCoolAPICloudWatchRole",
"Arn"
]
},
"FieldLogLevel": "ALL"
},
"Name": "SuperCoolAPI",
"OwnerContact": "blah-blah",
"Tags": [
{
"Key": "graphqlapi:createdBy",
"Value": "SAM"
}
],
"Visibility": "PRIVATE"
},
"Type": "AWS::AppSync::GraphQLApi"
},
"SuperCoolAPICloudWatchRole": {
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": [
"sts:AssumeRole"
],
"Effect": "Allow",
"Principal": {
"Service": [
"appsync.amazonaws.com"
]
}
}
],
"Version": "2012-10-17"
},
"ManagedPolicyArns": [
{
"Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSAppSyncPushToCloudWatchLogs"
}
]
},
"Type": "AWS::IAM::Role"
},
"SuperCoolAPISchema": {
"Properties": {
"ApiId": {
"Fn::GetAtt": [
"SuperCoolAPI",
"ApiId"
]
},
"Definition": "type Mutation {\n addTodo(id: ID!, name: String, description: String, priority: Int): Todo\n}\n"
},
"Type": "AWS::AppSync::GraphQLSchema"
}
}
}
Loading