我正在学习如何使用 CDK,并提出了一个项目来帮助我学习。我的计划是使用 CDK 创建 CI/CD 以更新 AWS Service Catalog 中产品组合中的产品。
我在这个项目中的第一步是创建一个产品组合并通过 CDK/CloudFormation 添加产品。
cdk --version -> 1.110.0 (build 32f00eb)
我当前的代码如下:
public class CdkJavaServiceCatalogStackextends Stack {
public CdkJavaServiceCatalogStack(final Construct scope, final String id) {
this(scope, id, null);
}
public CdkJavaServiceCatalogStack(final Construct scope, final String id, final StackProps props) {
super(scope, id, props);
// The code that defines your stack goes here
CfnPortfolio portfolio = new CfnPortfolio(this, "MyFirstPorfolio", CfnPortfolioProps.builder()
.displayName("MyPortfoliosDisplayName")
.providerName("MyPortfoliosProviderName")
.description("This is my demo description...")
.build());
CfnCloudFormationProduct product = new CfnCloudFormationProduct(portfolio, "someId", CfnCloudFormationProductProps.builder()
.name("Some name")
.description("Some description")
.owner("me")
.provisioningArtifactParameters() //problem is ocuring here
.build());
final CfnPortfolioProductAssociation association = new CfnPortfolioProductAssociation(this, "someAssociation", CfnPortfolioProductAssociationProps.builder()
.portfolioId(portfolio.getLogicalId())
.productId(product.getLogicalId())
.build());
}
我发现了一些类似的打字稿代码,但是,我在 java 中定义“provisioningArtifactParameters”时遇到了问题。
this.product = new servicecatalog.CfnCloudFormationProduct(this, 's3-product', {
name: 'Simple S3 Product',
description: 'This is an s3 product',
owner: 'whoever',
provisioningArtifactParameters: [
{
description: 'Product template description',
name: '1.0',
info: {
LoadTemplateFromURL: asset.s3Url
}
}
]
});
所以现在我需要一些指导......我一直在尝试将 typescript 解决方案中的参数转换为 IResolvable (software.amazon.awscdk.core) 或“List<? extends Object>' 我的问题是....如何将参数provisioningArtifactParameters
从打字稿解决方案转换为这些参数类型之一?
public CfnCloudFormationProductProps.Builder provisioningArtifactParameters(IResolvable provisioningArtifactParameters) {
this.provisioningArtifactParameters = provisioningArtifactParameters;
return this;
}
public CfnCloudFormationProductProps.Builder provisioningArtifactParameters(List<? extends Object> provisioningArtifactParameters) {
this.provisioningArtifactParameters = provisioningArtifactParameters;
return this;
}
我在这里过得很艰难,如果有任何反馈,我将不胜感激。