@@ -15,6 +15,7 @@ import (
1515
1616 "github.com/hashicorp/terraform/internal/addrs"
1717 "github.com/hashicorp/terraform/internal/collections"
18+ "github.com/hashicorp/terraform/internal/configs"
1819 "github.com/hashicorp/terraform/internal/lang"
1920 "github.com/hashicorp/terraform/internal/lang/marks"
2021 "github.com/hashicorp/terraform/internal/plans"
@@ -909,19 +910,55 @@ func (pc *PlannedChangeActionInvocationInstancePlanned) ChangeDescription() (*st
909910 return nil , nil
910911 }
911912
912- return & stacks.PlannedChange_ChangeDescription {
913- Description : & stacks.PlannedChange_ChangeDescription_ActionInvocationPlanned {
914- ActionInvocationPlanned : & stacks.PlannedChange_ActionInvocationInstance {
915- Addr : stacks .NewActionInvocationInStackAddr (addr ),
916- ProviderAddr : pc .Invocation .ProviderAddr .Provider .String (),
917-
918- ConfigValue : stacks .NewDynamicValue (
919- pc .Invocation .ConfigValue ,
920- pc .Invocation .SensitiveConfigPaths ,
921- ),
913+ invoke := stacks.PlannedChange_ActionInvocationInstance {
914+ Addr : stacks .NewActionInvocationInStackAddr (addr ),
915+ ProviderAddr : pc .Invocation .ProviderAddr .Provider .String (),
916+
917+ ConfigValue : stacks .NewDynamicValue (
918+ pc .Invocation .ConfigValue ,
919+ pc .Invocation .SensitiveConfigPaths ,
920+ ),
921+ }
922+
923+ switch at := pc .Invocation .ActionTrigger .(type ) {
924+ case * plans.LifecycleActionTrigger :
925+ triggerEvent := stacks .PlannedChange_INVALID_EVENT
926+ switch at .ActionTriggerEvent {
927+ case configs .BeforeCreate :
928+ triggerEvent = stacks .PlannedChange_BEFORE_CREATE
929+ case configs .AfterCreate :
930+ triggerEvent = stacks .PlannedChange_AFTER_CREATE
931+ case configs .BeforeUpdate :
932+ triggerEvent = stacks .PlannedChange_BEFORE_UPDATE
933+ case configs .AfterUpdate :
934+ triggerEvent = stacks .PlannedChange_AFTER_UPDATE
935+ case configs .BeforeDestroy :
936+ triggerEvent = stacks .PlannedChange_BEFORE_DESTROY
937+ case configs .AfterDestroy :
938+ triggerEvent = stacks .PlannedChange_AFTER_DESTROY
939+ }
922940
923- ActionTrigger : nil ,
941+ invoke .ActionTrigger = & stacks.PlannedChange_ActionInvocationInstance_LifecycleActionTrigger {
942+ LifecycleActionTrigger : & stacks.PlannedChange_LifecycleActionTrigger {
943+ TriggerEvent : triggerEvent ,
944+ TriggeringResourceAddress : stacks .NewResourceInstanceInStackAddr (stackaddrs.AbsResourceInstance {
945+ Component : addr .Component ,
946+ Item : at .TriggeringResourceAddr ,
947+ }),
948+ ActionTriggerBlockIndex : int64 (at .ActionTriggerBlockIndex ),
949+ ActionsListIndex : int64 (at .ActionsListIndex ),
924950 },
951+ }
952+ case * plans.InvokeActionTrigger :
953+ invoke .ActionTrigger = new (stacks.PlannedChange_ActionInvocationInstance_InvokeActionTrigger )
954+ default :
955+ // This should be exhaustive
956+ return nil , fmt .Errorf ("unsupported action trigger type: %T" , at )
957+ }
958+
959+ return & stacks.PlannedChange_ChangeDescription {
960+ Description : & stacks.PlannedChange_ChangeDescription_ActionInvocationPlanned {
961+ ActionInvocationPlanned : & invoke ,
925962 },
926963 }, nil
927964}
0 commit comments