Aws CDK create sampling rule

0

hey people, can someone point out error in this instantiation? I tested this rule in console and it seems to work

import * as xray from 'aws-cdk-lib/aws-xray';
    
new xray.CfnSamplingRule(this, 'ignoreHttpOptionsSamplingRule', {
      ruleName: 'ignoreOptionsRequest',
      samplingRule: {
        fixedRate: 0,
        host: '*',
        httpMethod: 'OPTIONS',
        priority: 9999,
        reservoirSize: 0,
        resourceArn: '*',
        serviceName: '*',
        serviceType: '*',
        urlPath: '*',
        version: 1,
      },
    });

I get the following error

Resource handler returned message: "Invalid request provided: CreateSamplingRuleRequest(SamplingRule=SamplingRule(ResourceARN=*, Priority=9999, FixedRate=0.0, ReservoirSize=0, ServiceName=*, ServiceType=*, Host=*, HTTPMethod=OPTIONS, URLPath=*, Version=1))
1개 답변
0
수락된 답변

The comment here about cloudtrail helped me find the issue. It seems like the rule name in props is deprecated and ruleName is supported inside sampling rule. the final code that worked was

    new xray.CfnSamplingRule(this, 'ignoreHttpOptionsSamplingRule', {
      samplingRule: {
        ruleName: 'ignore-options-request',
        httpMethod: 'OPTIONS',
        resourceArn: '*',
        serviceName: '*',
        serviceType: '*',
        urlPath: '*',
        host: '*',
        version: 1,
        fixedRate: 0,
        priority: 9999,
        reservoirSize: 0,
      },
    });
b3
답변함 6달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠