Is there a way to get or create a resource? I’m tr...
# general
e
Is there a way to get or create a resource? I’m trying to add a Cloudwatch log group subscription to a log group that may or may not exist when I deploy to different regions and accounts. When I try:
Copy code
let batchLogGroup = null;
    try {
        batchLogGroup = aws.cloudwatch.LogGroup.get(`batch-log-group-${region}`, '/aws/batch/job', {},  {provider})
    } catch (e) {
        batchLogGroup = new aws.cloudwatch.LogGroup(`batch-log-group-${region}`, {name: "/aws/batch/job", retentionInDays: 7}, {provider})
    }
I get `error:
Preview failed: resource ‘/aws/batch/job’ does not exist
.
f
Please see this issue: https://github.com/pulumi/pulumi/issues/3364#issuecomment-602898866 — you can use the workaround suggested by @white-balloon-205 in the comment to use
aws.cloudwatch.getLogGroup
instead of
.get
e
thanks!