Skip to content

Commit

Permalink
[Do not merge] Temporarily delete resources for CDK2 upgrade
Browse files Browse the repository at this point in the history
Upgrading straight to CDK2 leads to conflictin resources being created, so it is necessary to do thet upgrade in two stage:
1. Upgrade most components, except for the conflicting resources which should be deleted in this step by using this modified `egress_backend_stack.py`.
2. Deploy without this change
  • Loading branch information
manics committed Nov 15, 2023
1 parent 4c5ca2f commit 74aab6d
Showing 1 changed file with 87 additions and 87 deletions.
174 changes: 87 additions & 87 deletions egress_backend/egress_backend_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -1488,9 +1488,9 @@ def __init__(
)

# Subscribe lambda to SNS topic
swb_egress_topic.add_subscription(
subscriptions.LambdaSubscription(start_egress_workflow_function)
)
# swb_egress_topic.add_subscription(
# subscriptions.LambdaSubscription(start_egress_workflow_function)
# )

# Grant start execution permission on the step function to start_egress_workflow_function
data_egress_step_function.grant_start_execution(start_egress_workflow_function)
Expand Down Expand Up @@ -1536,79 +1536,79 @@ def __init__(
# Grant the api lambda permission to send task responses to the step function
data_egress_step_function.grant_task_response(egress_api_handler)

lambda_ds = appsync_api.add_lambda_data_source(
"lambdaDataSource", egress_api_handler
)

# Define lambda resolvers according to schema defintion
lambda_ds.create_resolver(
"listRequestsResolver",
type_name="Query",
field_name="listRequests",
request_mapping_template=appsync.MappingTemplate.from_string(
"""
{
"version": "2017-02-28",
"operation": "Invoke",
"payload": {
"field":"listRequests",
"email":$util.toJson($context.identity.claims.email),
"usergroup":$util.toJson($context.identity.claims.get("cognito:groups")),
"arguments": $util.toJson($context.arguments)
}
}
"""
),
response_mapping_template=appsync.MappingTemplate.from_string(
"""$util.toJson($context.result)"""
),
)

lambda_ds.create_resolver(
"updateRequestResolver",
type_name="Mutation",
field_name="updateRequest",
request_mapping_template=appsync.MappingTemplate.from_string(
"""
{
"version": "2017-02-28",
"operation": "Invoke",
"payload": {
"field":"updateRequest",
"email":$util.toJson($context.identity.claims.email),
"usergroup":$util.toJson($context.identity.claims.get("cognito:groups")),
"arguments": $util.toJson($context.arguments)
}
}
"""
),
response_mapping_template=appsync.MappingTemplate.from_string(
"""$util.toJson($context.result)"""
),
)

lambda_ds.create_resolver(
"downloadDataResolver",
type_name="Mutation",
field_name="downloadData",
request_mapping_template=appsync.MappingTemplate.from_string(
"""
{
"version": "2017-02-28",
"operation": "Invoke",
"payload": {
"field":"downloadData",
"email":$util.toJson($context.identity.claims.email),
"usergroup":$util.toJson($context.identity.claims.get("cognito:groups")),
"arguments": $util.toJson($context.arguments)
}
}
"""
),
response_mapping_template=appsync.MappingTemplate.from_string(
"""$util.toJson($context.result)"""
),
)
# lambda_ds = appsync_api.add_lambda_data_source(
# "lambdaDataSource", egress_api_handler
# )

# # Define lambda resolvers according to schema defintion
# lambda_ds.create_resolver(
# "listRequestsResolver",
# type_name="Query",
# field_name="listRequests",
# request_mapping_template=appsync.MappingTemplate.from_string(
# """
# {
# "version": "2017-02-28",
# "operation": "Invoke",
# "payload": {
# "field":"listRequests",
# "email":$util.toJson($context.identity.claims.email),
# "usergroup":$util.toJson($context.identity.claims.get("cognito:groups")),
# "arguments": $util.toJson($context.arguments)
# }
# }
# """
# ),
# response_mapping_template=appsync.MappingTemplate.from_string(
# """$util.toJson($context.result)"""
# ),
# )

# lambda_ds.create_resolver(
# "updateRequestResolver",
# type_name="Mutation",
# field_name="updateRequest",
# request_mapping_template=appsync.MappingTemplate.from_string(
# """
# {
# "version": "2017-02-28",
# "operation": "Invoke",
# "payload": {
# "field":"updateRequest",
# "email":$util.toJson($context.identity.claims.email),
# "usergroup":$util.toJson($context.identity.claims.get("cognito:groups")),
# "arguments": $util.toJson($context.arguments)
# }
# }
# """
# ),
# response_mapping_template=appsync.MappingTemplate.from_string(
# """$util.toJson($context.result)"""
# ),
# )

# lambda_ds.create_resolver(
# "downloadDataResolver",
# type_name="Mutation",
# field_name="downloadData",
# request_mapping_template=appsync.MappingTemplate.from_string(
# """
# {
# "version": "2017-02-28",
# "operation": "Invoke",
# "payload": {
# "field":"downloadData",
# "email":$util.toJson($context.identity.claims.email),
# "usergroup":$util.toJson($context.identity.claims.get("cognito:groups")),
# "arguments": $util.toJson($context.arguments)
# }
# }
# """
# ),
# response_mapping_template=appsync.MappingTemplate.from_string(
# """$util.toJson($context.result)"""
# ),
# )

# Define CDK NAG Rule Suppressions
NagSuppressions.add_resource_suppressions(
Expand Down Expand Up @@ -1931,17 +1931,17 @@ def __init__(
],
True,
)
NagSuppressions.add_resource_suppressions_by_path(
self,
f"/{self.stack_name}/Egress-Api/lambdaDataSource/ServiceRole/DefaultPolicy/Resource",
[
{
"id": "AwsSolutions-IAM5",
"reason": "Wildcard permissions are required",
}
],
True,
)
# NagSuppressions.add_resource_suppressions_by_path(
# self,
# f"/{self.stack_name}/Egress-Api/lambdaDataSource/ServiceRole/DefaultPolicy/Resource",
# [
# {
# "id": "AwsSolutions-IAM5",
# "reason": "Wildcard permissions are required",
# }
# ],
# True,
# )
NagSuppressions.add_resource_suppressions_by_path(
self,
f"/{self.stack_name}/Egress-Api/ApiLogsRole/Resource",
Expand Down

0 comments on commit 74aab6d

Please sign in to comment.