Skip to content

Commit 6be9fed

Browse files
authored
Merge pull request #49 from nshalabh/main
fix: updated documentation for ServiceNow integration setup; missing dependencies for lambdas; updated deploy script to upload the private key from local filepath to s3 before being used in the cdk for deployment; updated cdk to use the new s3 bucket (instead of assets as it requires resolution of filepath at runtime)
2 parents 84df429 + 70c79ab commit 6be9fed

File tree

13 files changed

+176
-121
lines changed

13 files changed

+176
-121
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
boto3>=1.37.7
2-
jira
2+
jira
3+
requests>=2.31.0
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
boto3>=1.37.7
22
aws-lambda-powertools>=2.30.2
33
requests>=2.31.0
4-
pysnc
4+
pysnc==1.0.2
5+
PyJWT==2.8.0
6+
cryptography==41.0.7
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
boto3>=1.37.7
2-
pysnc
2+
pysnc==1.0.2
3+
PyJWT==2.8.0
4+
cryptography==41.0.7

assets/service_now_notifications_handler/index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
logger.setLevel(logging.INFO) # Set to INFO first
3131

3232
# Get log level from environment variable
33-
log_level = os.environ.get("LOG_LEVEL", "error").lower()
33+
log_level = os.environ.get("LOG_LEVEL", "info").lower()
3434
print(f"LOG_LEVEL environment variable: {log_level}") # Debug print
3535
if log_level == "debug":
3636
logger.setLevel(logging.DEBUG)
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
boto3>=1.37.7
2-
pysnc
3-
aws-lambda-powertools>=2.30.0
2+
pysnc==1.0.2
3+
aws-lambda-powertools>=2.30.0
4+
PyJWT==2.8.0
5+
cryptography==41.0.7

assets/service_now_resource_setup_handler/index.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@
1212
import uuid
1313
import jwt
1414

15-
try:
16-
# This import works for lambda function and imports the lambda layer at runtime
17-
from service_now_wrapper import ServiceNowJWTAuth
18-
except ImportError:
19-
# This import works for local development and imports locally from the file system
20-
from ..wrappers.python.service_now_wrapper import ServiceNowJWTAuth
15+
# ServiceNowJWTAuth is not used in this file, removing the import
2116

2217
# Configure logging
2318
logger = logging.getLogger()
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
requests==2.32.4
2-
boto3==1.34.0
2+
boto3==1.34.0
3+
PyJWT==2.8.0
4+
cryptography==41.0.7
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
boto3>=1.37.7
2+
requests>=2.31.0

assets/wrappers/python/service_now_wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def __create_client(self) -> Optional[SnowClient]:
252252
encoded_jwt = self.__get_encoded_jwt(client_id, user_id)
253253

254254
# Preparing ServiceNowJWTAuth for ServiceNowClient
255-
auth = ServiceNowJWTAuth(client_id, client_secret, encoded_jwt)
255+
auth = ServiceNowJWTAuth(self.instance_id, client_id, client_secret, encoded_jwt)
256256

257257
return SnowClient(instance_url, auth)
258258

aws_security_incident_response_sample_integrations/aws_security_incident_response_service_now_integration_stack.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ def __init__(
9696
description="The ServiceNow user ID for JWT authentication.",
9797
)
9898

99-
# Private key file path parameter
100-
private_key_path_param = CfnParameter(
99+
# Private key bucket parameter (from deploy script)
100+
private_key_bucket_param = CfnParameter(
101101
self,
102-
"privateKeyPath",
102+
"privateKeyBucket",
103103
type="String",
104-
description="Local file path to private key file.",
104+
description="S3 bucket name containing the private key file.",
105105
)
106106

107107
# Integration module parameter
@@ -142,13 +142,12 @@ def __init__(
142142
)
143143
service_now_user_id_ssm.apply_removal_policy(RemovalPolicy.DESTROY)
144144

145-
# Create S3 bucket for private key storage
145+
# Use existing S3 bucket from deploy script
146146
from aws_cdk import aws_s3 as s3
147-
private_key_bucket = s3.Bucket(
147+
private_key_bucket = s3.Bucket.from_bucket_name(
148148
self,
149149
"ServiceNowPrivateKeyBucket",
150-
removal_policy=RemovalPolicy.DESTROY,
151-
auto_delete_objects=True,
150+
private_key_bucket_param.value_as_string
152151
)
153152

154153
# Create SSM parameters for S3 bucket location
@@ -834,10 +833,4 @@ def __init__(
834833
description="ServiceNow Webhook API Gateway URL",
835834
)
836835

837-
# Output S3 bucket for private key
838-
CfnOutput(
839-
self,
840-
"PrivateKeyBucket",
841-
value=private_key_bucket.bucket_name,
842-
description="S3 bucket where private key should be uploaded as 'private.key'",
843-
)
836+

0 commit comments

Comments
 (0)