question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose props as read/write properties in CFN resources and remove propertyOverrides

See original GitHub issue

Perfectly reasonable application of aspects came up on Gitter:

Hello, I’m trying to write a custom IAspect which sets the RoleName of any IAM Role in a stack to include a particular prefix (for resource matching in IAM permissions). Unfortunately, this overrides any RoleName that is manually set in the stack itself. Is there a way for an IAspect to check whether an IAM Role already has RoleName set?

To enable this we would need to allow read/write access to the configured properties of a CfnResource, in a typed fashion (so it needs to be done in cfn2ts).

We need to think about types and JSII though.

A RoleProps struct will have readonly properties for evertyhing, so cannot be mutated. So the syntax will have to be something like:

cfnrole.properties = {
   ...cfnrole.properties, 
   roleName: 'MyPrefix-' + cfnrole.properties.roleName
};

Not great…

Same story across JSII, except in Javaland it will be even more annoying to copy the existing properties into a new builder object. We need to generate a “copy constructor” as well then.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
RomainMullercommented, Apr 16, 2019

We could also code generate an IInterface for that mutable property. This should also feature an arbitrary accessor ([key: string]: any) so people could leverage properties that did t make it to the spec yet.

It’d maintain the namespace-like encapsulation that prevents name collisions from being a problem, and retain the strong typed overrides. It may need a JSII feature to support objects with an index signature.

0reactions
moofish32commented, Apr 23, 2019

I’m digging in here, the code needs a little unwinding. Hopefully I’ll have something in a couple of days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Abstractions and escape hatches - AWS Documentation
These map 1:1 to all available AWS CloudFormation resources and properties. These resources can be recognized by their name starting with Cfn ,...
Read more >
awsimagebuilder - Go Packages
Create a new `AWS::ImageBuilder::DistributionConfiguration`. ... Resources that expose mutable properties should override this function to // collect and ...
Read more >
How to use Cfn Resources in AWS CDK - Complete Guide
Let's create a Dynamodb table using the CfnResource class. What we'll notice is that we're basically using CloudFormation, the property casing as well...
Read more >
My Study Notes on AWS Cloud Development Kit (AWS CDK)
(Find a clean AWS Region or use AWS Organizations to create a clean AWS ... CFN Resources are generated from the AWS CloudFormation...
Read more >
NiFi System Administrator's Guide - Apache NiFi
properties and login-identity-providers.xml to take effect, NiFi needs to be restarted. If NiFi is clustered, configuration files must be the same on all...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found