44from aws_cdk import CfnOutput , Duration , RemovalPolicy , Stack
55from aws_cdk import aws_apigateway as apigateway
66from aws_cdk import aws_apigatewayv2_alpha , aws_apigatewayv2_integrations_alpha
7- from aws_cdk import aws_cognito as cognito
87from aws_cdk import aws_dynamodb as dynamodb
98from aws_cdk import aws_ec2 as ec2
109from aws_cdk import aws_iam as iam
@@ -31,10 +30,6 @@ def __init__(
3130 super ().__init__ (scope , construct_id , ** kwargs )
3231
3332 self .table = self .build_table ()
34- self .user_pool = cognito .UserPool .from_user_pool_id (
35- self , "cognito-user-pool" , config .userpool_id
36- )
37- self .jwks_url = self .build_jwks_url (config .userpool_id )
3833 db_security_group = ec2 .SecurityGroup .from_security_group_id (
3934 self ,
4035 "db-security-group" ,
@@ -43,21 +38,17 @@ def __init__(
4338
4439 lambda_env = {
4540 "DYNAMODB_TABLE" : self .table .table_name ,
46- "JWKS_URL" : self .jwks_url ,
4741 "NO_PYDANTIC_SSM_SETTINGS" : "1" ,
4842 "STAC_URL" : config .veda_stac_api_cf_url ,
49- "USERPOOL_ID" : config .userpool_id ,
50- "CLIENT_ID" : config .client_id ,
51- "CLIENT_SECRET" : config .client_secret ,
5243 "RASTER_URL" : config .veda_raster_api_cf_url ,
5344 "ROOT_PATH" : config .ingest_root_path ,
5445 "STAGE" : config .stage ,
55- "COGNITO_DOMAIN" : str (config .cognito_domain ),
46+ "CLIENT_ID" : config .keycloak_ingest_api_client_id ,
47+ "OPENID_CONFIGURATION_URL" : str (config .openid_configuration_url ),
5648 }
5749
5850 build_api_lambda_params = {
5951 "table" : self .table ,
60- "user_pool" : self .user_pool ,
6152 "db_secret" : db_secret ,
6253 "db_vpc" : db_vpc ,
6354 "db_security_group" : db_security_group ,
@@ -115,7 +106,6 @@ def build_api_lambda(
115106 * ,
116107 table : dynamodb .ITable ,
117108 env : Dict [str , str ],
118- user_pool : cognito .IUserPool ,
119109 db_secret : secretsmanager .ISecret ,
120110 db_vpc : ec2 .IVpc ,
121111 db_security_group : ec2 .ISecurityGroup ,
@@ -164,14 +154,6 @@ def build_api_lambda(
164154 handler .grant_principal ,
165155 "sts:AssumeRole" ,
166156 )
167-
168- handler .add_to_role_policy (
169- iam .PolicyStatement (
170- actions = ["cognito-idp:AdminInitiateAuth" ],
171- resources = [user_pool .user_pool_arn ],
172- )
173- )
174-
175157 # Allow handler to read DB secret
176158 db_secret .grant_read (handler )
177159
@@ -216,13 +198,6 @@ def build_api(
216198 disable_execute_api_endpoint = disable_default_apigw_endpoint ,
217199 )
218200
219- def build_jwks_url (self , userpool_id : str ) -> str :
220- region = userpool_id .split ("_" )[0 ]
221- return (
222- f"https://cognito-idp.{ region } .amazonaws.com"
223- f"/{ userpool_id } /.well-known/jwks.json"
224- )
225-
226201 # item ingest table, comsumed by ingestor
227202 def build_table (self ) -> dynamodb .ITable :
228203 table = dynamodb .Table (
@@ -260,9 +235,6 @@ def __init__(
260235 "DYNAMODB_TABLE" : table .table_name ,
261236 "NO_PYDANTIC_SSM_SETTINGS" : "1" ,
262237 "STAC_URL" : config .veda_stac_api_cf_url ,
263- "USERPOOL_ID" : config .userpool_id ,
264- "CLIENT_ID" : config .client_id ,
265- "CLIENT_SECRET" : config .client_secret ,
266238 "RASTER_URL" : config .veda_raster_api_cf_url ,
267239 }
268240
0 commit comments