If you enable cluster logging in EKS, it creates a...
# aws
l
If you enable cluster logging in EKS, it creates a log group as a 'side effect', but it isn't directly exposed or added into Pulumi's state. I'd like to bring this resource under control of my pulumi program after it gets created so I can modify it (ruling out a simple
.get
), but the
import
resource option isn't designed for that use-case. Is there a way to import that resource during my programs initial run without resorting to importing it after the fact?
ah, looks like I can use the
id
resource option, I skipped over that when reading
r
so are you importing it? how do you plan to use this? im curious because if you remove the “cluster logging” you will loose those logs but pulumi will want to create them
l
When you enable EKS logging, it creates a log group for you with unlimited retention. I want to manage that log group with pulumi so I can set the retention to 14d. Since this resource is created as a side-effect, I don't want to have to manually import it into my state after deployment, imo I should be able to specify that the resource is going to be created and I want it managed. The id resource option allows you to load an existing resource rather than have pulumi create it, so that allows me to get it into state. Unfortunately it looks like pulumi doesn't then allow you to apply changes to the resource though, eg this brings it into state but doesn't actually make the retention change:
Copy code
this.clusterLogGroup = new aws.cloudwatch.LogGroup('eks-cluster-log-group', {
      name: pulumi.interpolate`/aws/eks/${this.clusterName}/cluster`,
      retentionInDays: 14
    }, {
      parent: this,
      dependsOn: this.eks,
      id: pulumi.interpolate`/aws/eks/${this.clusterName}/cluster`
    })
so I'm a little stuck on it atm
The alternative is to create the log group before the cluster, but then we run into the issue of having to deal with it potentially already existing etc
Interestingly, the only difference between a resource that was created by Pulumi and a resource that has its
id:
set (and has therefore been imported into state) is the
external: true
field in the state. If you remove that field, it simply acts as if Pulumi created it and allows you to modify it.
I raised https://github.com/pulumi/pulumi/issues/17640 to discuss it since I don't think what I want is actually supported