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

Include section in DataSource logical id #3070

Merged
merged 3 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion samtranslator/model/sam_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -2286,7 +2286,7 @@ def _construct_ddb_datasources(
resources: List[Resource] = []

for relative_id, ddb_datasource in ddb_datasources.items():
datasource_logical_id = self.logical_id + relative_id
datasource_logical_id = f"{self.logical_id}DynamoDBDataSource{relative_id}"
cfn_datasource = DataSource(
logical_id=datasource_logical_id, depends_on=self.depends_on, attributes=self.resource_attributes
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
"Type": "AWS::IAM::Role"
},
"SuperCoolAPIMyDataSource": {
"SuperCoolAPIDynamoDBDataSourceMyDataSource": {
"Properties": {
"ApiId": {
"Fn::GetAtt": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,33 @@
},
"Type": "AWS::AppSync::GraphQLApi"
},
"SuperCoolAPIAnotherDataSource": {
"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"
},
"SuperCoolAPIDynamoDBDataSourceAnotherDataSource": {
"Properties": {
"ApiId": {
"Fn::GetAtt": [
Expand All @@ -44,15 +70,15 @@
"Name": "AnotherDataSource",
"ServiceRoleArn": {
"Fn::GetAtt": [
"SuperCoolAPIAnotherDataSourceRole",
"SuperCoolAPIDynamoDBDataSourceAnotherDataSourceRole",
"Arn"
]
},
"Type": "AMAZON_DYNAMODB"
},
"Type": "AWS::AppSync::DataSource"
},
"SuperCoolAPIAnotherDataSourceRole": {
"SuperCoolAPIDynamoDBDataSourceAnotherDataSourceRole": {
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
Expand All @@ -73,10 +99,10 @@
},
"Type": "AWS::IAM::Role"
},
"SuperCoolAPIAnotherDataSourceToTableConnectorPolicy": {
"SuperCoolAPIDynamoDBDataSourceAnotherDataSourceToTableConnectorPolicy": {
"Metadata": {
"aws:sam:connectors": {
"SuperCoolAPIAnotherDataSourceToTableConnector": {
"SuperCoolAPIDynamoDBDataSourceAnotherDataSourceToTableConnector": {
"Destination": {
"Type": "AWS::DynamoDB::Table"
},
Expand Down Expand Up @@ -139,39 +165,13 @@
},
"Roles": [
{
"Ref": "SuperCoolAPIAnotherDataSourceRole"
"Ref": "SuperCoolAPIDynamoDBDataSourceAnotherDataSourceRole"
}
]
},
"Type": "AWS::IAM::ManagedPolicy"
},
"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"
},
"SuperCoolAPIMyDataSource": {
"SuperCoolAPIDynamoDBDataSourceMyDataSource": {
"Properties": {
"ApiId": {
"Fn::GetAtt": [
Expand All @@ -188,15 +188,15 @@
"Name": "MyDataSource",
"ServiceRoleArn": {
"Fn::GetAtt": [
"SuperCoolAPIMyDataSourceRole",
"SuperCoolAPIDynamoDBDataSourceMyDataSourceRole",
"Arn"
]
},
"Type": "AMAZON_DYNAMODB"
},
"Type": "AWS::AppSync::DataSource"
},
"SuperCoolAPIMyDataSourceRole": {
"SuperCoolAPIDynamoDBDataSourceMyDataSourceRole": {
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
Expand All @@ -217,10 +217,10 @@
},
"Type": "AWS::IAM::Role"
},
"SuperCoolAPIMyDataSourceToTableConnectorPolicy": {
"SuperCoolAPIDynamoDBDataSourceMyDataSourceToTableConnectorPolicy": {
"Metadata": {
"aws:sam:connectors": {
"SuperCoolAPIMyDataSourceToTableConnector": {
"SuperCoolAPIDynamoDBDataSourceMyDataSourceToTableConnector": {
"Destination": {
"Type": "AWS::DynamoDB::Table"
},
Expand Down Expand Up @@ -283,7 +283,7 @@
},
"Roles": [
{
"Ref": "SuperCoolAPIMyDataSourceRole"
"Ref": "SuperCoolAPIDynamoDBDataSourceMyDataSourceRole"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"Type": "AWS::IAM::Role"
},
"SuperCoolAPIMyDataSource": {
"SuperCoolAPIDynamoDBDataSourceMyDataSource": {
"Properties": {
"ApiId": {
"Fn::GetAtt": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"Type": "AWS::IAM::Role"
},
"SuperCoolAPIMyDataSource": {
"SuperCoolAPIDynamoDBDataSourceMyDataSource": {
"Properties": {
"ApiId": {
"Fn::GetAtt": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"Type": "AWS::IAM::Role"
},
"SuperCoolAPIMyDataSource": {
"SuperCoolAPIDynamoDBDataSourceMyDataSource": {
"Properties": {
"ApiId": {
"Fn::GetAtt": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
"Type": "AWS::IAM::Role"
},
"SuperCoolAPIMyDataSource": {
"SuperCoolAPIDynamoDBDataSourceMyDataSource": {
"Properties": {
"ApiId": {
"Fn::GetAtt": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,33 @@
},
"Type": "AWS::AppSync::GraphQLApi"
},
"SuperCoolAPIAnotherDataSource": {
"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"
},
"SuperCoolAPIDynamoDBDataSourceAnotherDataSource": {
"Properties": {
"ApiId": {
"Fn::GetAtt": [
Expand All @@ -44,15 +70,15 @@
"Name": "AnotherDataSource",
"ServiceRoleArn": {
"Fn::GetAtt": [
"SuperCoolAPIAnotherDataSourceRole",
"SuperCoolAPIDynamoDBDataSourceAnotherDataSourceRole",
"Arn"
]
},
"Type": "AMAZON_DYNAMODB"
},
"Type": "AWS::AppSync::DataSource"
},
"SuperCoolAPIAnotherDataSourceRole": {
"SuperCoolAPIDynamoDBDataSourceAnotherDataSourceRole": {
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
Expand All @@ -73,10 +99,10 @@
},
"Type": "AWS::IAM::Role"
},
"SuperCoolAPIAnotherDataSourceToTableConnectorPolicy": {
"SuperCoolAPIDynamoDBDataSourceAnotherDataSourceToTableConnectorPolicy": {
"Metadata": {
"aws:sam:connectors": {
"SuperCoolAPIAnotherDataSourceToTableConnector": {
"SuperCoolAPIDynamoDBDataSourceAnotherDataSourceToTableConnector": {
"Destination": {
"Type": "AWS::DynamoDB::Table"
},
Expand Down Expand Up @@ -139,39 +165,13 @@
},
"Roles": [
{
"Ref": "SuperCoolAPIAnotherDataSourceRole"
"Ref": "SuperCoolAPIDynamoDBDataSourceAnotherDataSourceRole"
}
]
},
"Type": "AWS::IAM::ManagedPolicy"
},
"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"
},
"SuperCoolAPIMyDataSource": {
"SuperCoolAPIDynamoDBDataSourceMyDataSource": {
"Properties": {
"ApiId": {
"Fn::GetAtt": [
Expand All @@ -188,15 +188,15 @@
"Name": "MyDataSource",
"ServiceRoleArn": {
"Fn::GetAtt": [
"SuperCoolAPIMyDataSourceRole",
"SuperCoolAPIDynamoDBDataSourceMyDataSourceRole",
"Arn"
]
},
"Type": "AMAZON_DYNAMODB"
},
"Type": "AWS::AppSync::DataSource"
},
"SuperCoolAPIMyDataSourceRole": {
"SuperCoolAPIDynamoDBDataSourceMyDataSourceRole": {
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
Expand All @@ -217,10 +217,10 @@
},
"Type": "AWS::IAM::Role"
},
"SuperCoolAPIMyDataSourceToTableConnectorPolicy": {
"SuperCoolAPIDynamoDBDataSourceMyDataSourceToTableConnectorPolicy": {
"Metadata": {
"aws:sam:connectors": {
"SuperCoolAPIMyDataSourceToTableConnector": {
"SuperCoolAPIDynamoDBDataSourceMyDataSourceToTableConnector": {
"Destination": {
"Type": "AWS::DynamoDB::Table"
},
Expand Down Expand Up @@ -283,7 +283,7 @@
},
"Roles": [
{
"Ref": "SuperCoolAPIMyDataSourceRole"
"Ref": "SuperCoolAPIDynamoDBDataSourceMyDataSourceRole"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"Type": "AWS::IAM::Role"
},
"SuperCoolAPIMyDataSource": {
"SuperCoolAPIDynamoDBDataSourceMyDataSource": {
"Properties": {
"ApiId": {
"Fn::GetAtt": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"Type": "AWS::IAM::Role"
},
"SuperCoolAPIMyDataSource": {
"SuperCoolAPIDynamoDBDataSourceMyDataSource": {
"Properties": {
"ApiId": {
"Fn::GetAtt": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"Type": "AWS::IAM::Role"
},
"SuperCoolAPIMyDataSource": {
"SuperCoolAPIDynamoDBDataSourceMyDataSource": {
"Properties": {
"ApiId": {
"Fn::GetAtt": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
"Type": "AWS::IAM::Role"
},
"SuperCoolAPIMyDataSource": {
"SuperCoolAPIDynamoDBDataSourceMyDataSource": {
"Properties": {
"ApiId": {
"Fn::GetAtt": [
Expand Down
Loading