late-balloon-24601
11/18/2024, 12:19 PM/**
* A string that will only be set once and will not change on subsequent updates, even if the input changes.
* The 'keepers' field can be used to force a new value to be used.
*/
export class PersistentString extends random.RandomShuffle {
constructor (name: string, input: PersistentStringArgs, opts?: pulumi.CustomResourceOptions) {
super(name, {
inputs: [input.value],
resultCount: 1,
keepers: input.keepers
}, pulumi.mergeOptions(opts, { ignoreChanges: ['inputs'] }))
}
}quick-house-41860
11/18/2024, 4:20 PMignoreChanges directly on the resource where you're setting the AMI ID?late-balloon-24601
11/18/2024, 4:21 PMquick-house-41860
11/18/2024, 4:27 PMlate-balloon-24601
11/18/2024, 4:28 PMclever-sunset-76585
11/18/2024, 6:52 PMcreate method to return a result with the initial AMI ID and also always the same ID from the update too until you change the keepers input to the dynamic resource. The diff method in the provider callback allows you to detect which property changed. So when the keepers property changes, trigger another call to fetch the AMI ID from SSM again.little-cartoon-10569
11/18/2024, 7:15 PMThe only other option I can think of right now would be splitting this into two stacks.Projects 🙂
hallowed-baker-22997
11/20/2024, 11:35 PMconst sample = Date.now(); // changes every time run
const trigger = 1; // but only captured when this value changes
const cache = new command.local.Command("cache", {
create: pulumi.interpolate`echo "${sample}"`,
triggers: [trigger],
}, { ignoreChanges: ["create"] })
export const output = cache.stdout;