I’ve got a cdk pipeline and want to add my lambda stage, however getting this error below.
jsii.errors.JavaScriptError:
Error: ENAMETOOLONG: name too long, mkdir 'cdk.out
class LambdaStage(Stage):
def __init__(self, scope: Construct, id: str, **kwargs) -> None:
super().__init__(scope, id, **kwargs)
ProtectionGroupStage(
self,
'ProtectionGroupStage',
**kwargs,
)
class PipelineStack(Stack):
def __init__(self, scope: Construct, id: str, **kwargs) -> None:
super().__init__(scope, id, **kwargs)
pipeline_source = pipelines.CodePipelineSource.connection(xxxx)
pipeline = pipelines.CodePipeline(
self,
"ShieldAdvancedPipeline",
synth=pipelines.ShellStep(
"Synth",
input=pipeline_source,
commands=[
"npm install -g aws-cdk",
"pip install poetry==1.8.2",
"cdk synth"
],
),
)
deploy = LambdaStage(self, "Deploy")
deploy_stage = pipeline.add_stage(deploy)
I just want to add my lambda stage to be added to my cdk pipeline i’ve created.
Lambda code below which gets cloudfront distributions which I will be storing into an s3 bucket to use later in my pipeline
def get_unprotected_arns(filter_substring, s3_bucket_name, s3_object_key):
session = boto3.Session(
aws_access_key_id=os.environ['AWS_ACCESS_KEY_ID'],
aws_secret_access_key=os.environ['AWS_SECRET_ACCESS_KEY'],
aws_session_token=os.environ['AWS_SESSION_TOKEN']
)
client = session.boto3.client('cloudfront')
paginator = client.get_paginator('list_distributions')
arns = []
for page in paginator.paginate():
for distribution in page['DitributionList']['Items']:
if any(filter_substring in domain for domain in distribution['Aliases']['Items']):
arn = distribution['ARN']
arns.append(arn)
unprotected_arns = [arn for arn in arns if arn not in list_existing_protections(session)]
s3_client = session.client('s3')
s3_client.put(
Bucket=s3_bucket_name,
Key=s3_object_key,
Body=json.dumps(unprotected_arns)
)
return unprotected_arns