Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

461
Visualizações
How to solve circular dependency between AWS resources using AWS CDK

I am creating S3, SQS, and KMS resources using aws cdk. I enabled encryption on the S3 and SQS resources. When I enabled the notification from S3 to SQS, I am getting a circular dependency error. When I remove the KMS settings from my code, it works.

GitHub repo: https://github.com/techcoderunner/s3-sqs-kms-sample

from aws_cdk import aws_kms as kms
from aws_cdk import aws_s3 as s3
from aws_cdk import aws_sqs as sqs
from aws_cdk import aws_s3_notifications as s3notif

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

# Create the S3 bucket
bucket = s3.Bucket(
    self, "ssl_s3_bucket_raw_kms",
    bucket_name="ssl-s3-bucket-kms-raw",
    encryption=s3.BucketEncryption.KMS,
    encryption_key=kms_key,
)

# Create the SQS queue
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 = s3notif.SqsDestination(queue)
filter1 = s3.NotificationKeyFilter(prefix="home/")

# Attach notificaton event to S3 bucket
bucket.add_event_notification(s3.EventType.OBJECT_CREATED,notification,filter1)
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I opened a GitHub bug report for this.

It looks like the root problem is that the following condition is added to the KMS key:

CDK output template ssls3sqskmskey83E47315.Properties.KeyPolicy.Statement[1]:

{
    "Action": [
        "kms:Decrypt",
        "kms:Encrypt",
         "kms:ReEncrypt*",
         "kms:GenerateDataKey*"
     ],
     "Condition": {
        "ArnLike": {
            "aws:SourceArn": {
                "Fn::GetAtt": [
                    "ssls3bucketrawkms4B1E1122",
                    "Arn"
                 ]
             }
         }
     },
},

The S3 bucket depends on the KMS key for encryption, and the KMS key has a condition that depends on the S3 bucket.

Workaround

I was able to deploy the stack after using escape hatches to delete the condition:

# Delete the circular reference
cfn_kms_key = kms_key.node.default_child
cfn_kms_key.add_property_deletion_override("KeyPolicy.Statement.1")

workaround code available here

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda