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

Incorrect token resolution with RuleTargetInput/FieldAwareEventInput #3119

Closed
1 of 5 tasks
jogold opened this issue Jun 28, 2019 Β· 0 comments Β· Fixed by #3127 or MechanicalRock/tech-radar#14 Β· May be fixed by MechanicalRock/cdk-constructs#5, MechanicalRock/cdk-constructs#6 or MechanicalRock/cdk-constructs#7
Labels
needs-triage This issue or PR still needs to be triaged. p0

Comments

@jogold
Copy link
Contributor

jogold commented Jun 28, 2019 β€’

  • I'm submitting a ...

    • πŸͺ² bug report
    • πŸš€ feature request
    • πŸ“š construct library gap
    • ☎️ security issue or vulnerability => Please see policy
    • ❓ support request => Please see note at the top of this template.
  • What is the current behavior?

The RuleTargetInput static methods (FieldAwareEventInput) incorrectly resolve tokens.

The following

const stack = new Stack();
const rule = new Rule(stack, 'Rule', {
  schedule: Schedule.rate(Duration.minutes(1)),
});
class SomeTarget implements IRuleTarget {
  public constructor(private readonly input: RuleTargetInput) {}
  public bind() {
    return { id: 'T1', arn: 'ARN1', input: this.input };
  }
}

const bucket = new Bucket(stack, 'Bucket');

rule.addTarget(new SomeTarget(RuleTargetInput.fromObject({ bucketArn: bucket.bucketArn })));

results in (note the [object Object]):

{
  "Type": "AWS::Events::Rule",
  "Properties": {
    "ScheduleExpression": "rate(1 minute)",
    "State": "ENABLED",
    "Targets": [
      {
        "Arn": "ARN1",
        "Id": "T1",
        "Input": "{\"bucketArn\":\"[object Object]\"}"
      }
    ]
  }
}
{
  "Type": "AWS::Events::Rule",
  "Properties": {
    "ScheduleExpression": "rate(1 minute)",
    "State": "ENABLED",
    "Targets": [
      {
        "Arn": "ARN1",
        "Id": "T1",
        "Input": {
          "Fn::Join": [
            "",
            [
              "{\"bucketArn\":\"",
              {
                "Ref": "Bucket83908E77"
              },
              "\"}"
            ]
          ]
        }
      }
    ]
  }
}
  • Please tell us about your environment:

    • CDK CLI Version: 0.36.0
    • Module Version: 0.36.0
    • OS: Windows 10
    • Language:TypeScript
@jogold jogold added the needs-triage This issue or PR still needs to be triaged. label Jun 28, 2019
@rix0rrr rix0rrr added the p0 label Jun 28, 2019
jogold added a commit to jogold/aws-cdk that referenced this issue Jun 28, 2019
jogold added a commit to jogold/aws-cdk that referenced this issue Jun 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment