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

EventsRuleToSns - topicProps or topicsProps #219

Closed
defmementomori opened this issue Jun 11, 2021 · 2 comments · Fixed by #235
Closed

EventsRuleToSns - topicProps or topicsProps #219

defmementomori opened this issue Jun 11, 2021 · 2 comments · Fixed by #235
Labels
bug Something isn't working in-progress This issue is being actively worked on

Comments

@defmementomori
Copy link

I think it is supposed to update from [※1] to [※2] at Name column of table link below.
[※1]topicProps
[※2]topicsProps

https://github.com/awslabs/aws-solutions-constructs/tree/main/source/patterns/@aws-solutions-constructs/aws-events-rule-sns#pattern-construct-props

Reproduction Steps

wriing code at lib folder like below and run build

import * as cdk from '@aws-cdk/core';
// import * as iam from '@aws-cdk/aws-iam';
import { EventsRuleToSnsProps, EventsRuleToSns } from "@aws-solutions-constructs/aws-events-rule-sns";
export class CdkEventbridgeRuleStack extends cdk.Stack {
  
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    const envcode = new cdk.CfnParameter(this, "envcode", {
      type: "String",
      description: "envcode"
    });
  
    // this is a pattern to notify
    const patternToNotify={
      "source": [
        "aws.trustedadvisor"
      ],
      "detail-type": [
        "Trusted Advisor Check Item Refresh Notification"
      ],
      "detail": {
        "status": [
          "ERROR",
          "WARN"
        ],
        "check-name": ["Amazon EBS Public Snapshots"]
      }
    }


    const constructStack = new EventsRuleToSns(this, 'eveSns', {
      eventRuleProps: {
        eventPattern: patternToNotify,
        ruleName: `${envcode.valueAsString}-TrustedAdvisor-Notif`
      },
      topicProps:{
        topicName:`${envcode.valueAsString}-TrustedAdvisor-Notif`
      },
      enableEncryptionWithCustomerManagedKey: false
    });

    // // Grant yourself permissions to use the Customer Managed KMS Key
    // const policyStatement = new iam.PolicyStatement({
    //     actions: ["kms:Encrypt", "kms:Decrypt"],
    //     effect: iam.Effect.ALLOW,
    //     principals: [ new iam.AccountRootPrincipal() ],
    //     resources: [ "*" ]
    // });
    // constructStack.encryptionKeyProps?.alias?('alias/aws/sns')
  }
}

Error Log

 - error TS2345: Argument of type '{ eventRuleProps: { eventPattern: { source: string[]; "detail-type": string[]; detail: { status: string[]; "check-name": string[]; }; }; ruleName: string; }; topicProps: { topicName: string; }; enableEncryptionWithCustomerManagedKey: false; }' is not assignable to parameter of type 'EventsRuleToSnsProps'.
  Object literal may only specify known properties, but 'topicProps' does not exist in type 'EventsRuleToSnsProps'. Did you mean to write 'topicsProps'?

37       topicProps:{
         ~~~~~~~~~~~~
38         topicName:`${envcode.valueAsString}-TrustedAdvisor-Notif`
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
39       },
   ~~~~~~~


Found 1 error.

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: `tsc`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/kota.tomimatsu/.npm/_logs/2021-06-11T06_09_04_156Z-debug.log

Environment

  • CDK CLI Version :1.107.0
  • CDK Framework Version:1.106.1
  • AWS Solutions Constructs Version :1.106.1
  • OS :mac catalina10.15.7
  • Language :japanese

Other

It works (build and deploy successfully) when I update my source from [※1] to [※2] .
[※1]topicProps
[※2]topicsProps
I didn't know which is better to update document like above or update code from [※2] to [※1],
In my opinion , I think it's better to update code
because topicProps comes from sns.TopicProps (which is not sns.Topic[s]Props ).


This is 🐛 Bug Report

@defmementomori defmementomori added bug Something isn't working needs-triage The issue or PR still needs to be triaged labels Jun 11, 2021
@biffgaut
Copy link
Contributor

Thanks - we'll take a look!

@biffgaut biffgaut added in-progress This issue is being actively worked on and removed needs-triage The issue or PR still needs to be triaged labels Jun 25, 2021
@biffgaut
Copy link
Contributor

This should be released to the repos (npm, pypi, etc.) tonight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working in-progress This issue is being actively worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants