注入 CDKTF 多行令牌值

Inject CDKTF multiline token value

上下文:

    const cert = new SelfSignedCert(this.stack, `${certName}-sscert`, {
      keyAlgorithm: 'RSA',
      privateKeyPem: privateKey.privateKeyPem,
      subject: [{
        commonName,
        organization
      }],
      validityPeriodHours,
      allowedUses
    });

    const containerDefinitionConfig = {
      path: {
        path: ecsJsonTaskDefPath,
      },
      args: {
        ...
        'certPem': cert.certPem,
        ...
      }
    };

如果我尝试 运行 那样,我会收到以下错误:

Error: ECS Task Definition container_definitions is invalid: Error decoding JSON: invalid character '\n' in string literal

我尝试使用:

版本:

"cdktf": "^0.9.0",

  "terraformProviders": [
    "aws@~> 3.74.0",
    "random@~> 3.1.0",
    "tls@~> 3.1.0"
  ],

我相信它抱怨替换函数中的第一个 \n:Fn.replace(cert.certPem, Fn.rawString('/\n/'), Fn.rawString('\n'))