如何使用AWS CDK解决AWS资源之间的循环依赖

时间:2020-07-19 11:24:36

标签: amazon-web-services aws-cdk

我正在使用aws cdk创建S3,SQS,KMS资源。在S3和SQS中,我启用了加密。当我启用从s3到SQS的通知时,出现循环依赖错误。当我从代码中删除KMS设置时,它就可以工作。 当我使用启用的加密功能时,由于循环依赖性而失败。请帮助我,如何解决此问题。

我的Github存储库:https://github.com/techcoderunner/s3-sqs-kms-sample

       kms_key=kms.Key(self,
                        id='ssl_s3_sqs_kms_key'
                        ,alias = 'sslS3SqsKmsKey'
                        ,description='This is kms key'
                        ,enabled=True
                        ,enable_key_rotation=True
                        ,policy=kms_policy_document)

        

        #This will create the s3 bucket in AWS
        bucket = s3.Bucket(self,"ssl_s3_bucket_raw_kms",bucket_name="ssl-s3-bucket-kms-raw"
                            ,encryption=s3.BucketEncryption.KMS
                            ,encryption_key=kms_key
                            )
        
        #This will create the sqs in AWS
        queue = sqs.Queue(self,"ssl_sqs_event_queue",queue_name="ssl-sqs-kms-event-queue"
                            ,encryption=sqs.QueueEncryption.KMS
                            ,encryption_master_key=kms_key
                            )

        # #Create S3 notification object which points to SQS.
        notification = aws_s3_notifications.SqsDestination(queue)
        filter1=s3.NotificationKeyFilter(prefix="home/")
        
        # #Attach notificaton event to S3 bucket.
        bucket.add_event_notification(s3.EventType.OBJECT_CREATED,notification,filter1)

0 个答案:

没有答案