Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overriding allocateLogicalId not Working Python #8343

Closed
SKIIDK opened this issue Jun 3, 2020 · 6 comments
Closed

Overriding allocateLogicalId not Working Python #8343

SKIIDK opened this issue Jun 3, 2020 · 6 comments
Assignees
Labels
@aws-cdk/core Related to core CDK functionality guidance Question that needs advice or information. language/python Related to Python bindings needs-triage This issue or PR still needs to be triaged.

Comments

@SKIIDK
Copy link

SKIIDK commented Jun 3, 2020

❓ General Issue

The Question

I am trying to override the allocateLogicalId method in order to have an ARN without extraneous hash characters afterwards, but this does not seem to be working in Python. The TypeScript version was described by @skinny85 in #1424 , but when translating to Python, overriding allocate_logical_id does not seem to have an impact on the logical id's or the ARN's made from those id's.

Environment

  • CDK CLI Version: 1.41.0
  • Module Version:
  • Node.js Version: 12.16.3
  • OS: Ubuntu
  • Language (Version): Python 3.6.9

Other information

Doing my_resource.node.default_child.override_logical_id('new name') also doesn't seem to actually modify the names in the CDK and the names continue to have the hash characters following them.

@SKIIDK SKIIDK added the needs-triage This issue or PR still needs to be triaged. label Jun 3, 2020
@SomayaB SomayaB added language/python Related to Python bindings @aws-cdk/core Related to core CDK functionality guidance Question that needs advice or information. labels Jun 5, 2020
@SKIIDK
Copy link
Author

SKIIDK commented Jun 6, 2020

I think I was able to get around it by setting the specific name parameters for the construct, but I'm not sure if that's the proper way to approach it.

@eladb
Copy link
Contributor

eladb commented Jun 8, 2020

@RomainMuller any idea?

@RomainMuller
Copy link
Contributor

@SKIIDK - would you be able to show us the code you're using for your override attempt that is not working? Bonus points if that is stripped to a minimal reproduction 😬

@RomainMuller RomainMuller self-assigned this Jun 8, 2020
@SKIIDK
Copy link
Author

SKIIDK commented Jun 10, 2020

I ended up being able to get around it just by specifying the name parameters, but the override methods mentioned in that other thread don't seem the actual way to do it.

@SKIIDK SKIIDK closed this as completed Jun 10, 2020
@sarjarapu
Copy link

sarjarapu commented Jun 24, 2020

@RomainMuller here is my sample.

queue_name = 'my-queue'
queue = sqs.Queue(self, queue_name,
    visibility_timeout=core.Duration.seconds(300),
    receive_message_wait_time=core.Duration.seconds(20),
    encryption=sqs.QueueEncryption.KMS
)
cfnQueue = queue.node.default_child
cfnQueue.override_logical_id("myqueue")

after running cdk deploy the queue got created with similar my-cdk-myqueue-XXXXXXXXXXX.

I am not sure about @SKIIDK recommendation there is no name parameter in the Queue constructor.

@eladb eladb unassigned skinny85 and eladb Jun 29, 2020
@mw-vmaffet
Copy link

I was able to override allocateLogicalId in Python. The method is "protected" so its name is _allocate_logical_id.

Here is the example code translated:

class TestStack(Stack):

    def _allocate_logical_id(self, cfn_element: CfnElement) -> str:
        return cfn_element.node.id

Environment:

  • Python: 3.10.6
  • aws-cdk-lib: 2.37.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/core Related to core CDK functionality guidance Question that needs advice or information. language/python Related to Python bindings needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

7 participants