@@ -4035,3 +4035,66 @@ func TestContext2Plan_dataSourceReadPlanError(t *testing.T) {
40354035 t .Fatalf ("failed to round-trip through planfile: %s" , err )
40364036 }
40374037}
4038+
4039+ func TestContext2Plan_ignoredMarkedValue (t * testing.T ) {
4040+ m := testModuleInline (t , map [string ]string {
4041+ "main.tf" : `
4042+ resource "test_object" "a" {
4043+ map = {
4044+ prior = "value"
4045+ new = sensitive("ignored")
4046+ }
4047+ }
4048+ ` })
4049+
4050+ testProvider := & MockProvider {
4051+ GetProviderSchemaResponse : & providers.GetProviderSchemaResponse {
4052+ ResourceTypes : map [string ]providers.Schema {
4053+ "test_object" : providers.Schema {
4054+ Block : & configschema.Block {
4055+ Attributes : map [string ]* configschema.Attribute {
4056+ "map" : {
4057+ Type : cty .Map (cty .String ),
4058+ Optional : true ,
4059+ },
4060+ },
4061+ },
4062+ },
4063+ },
4064+ },
4065+ }
4066+
4067+ testProvider .PlanResourceChangeFn = func (req providers.PlanResourceChangeRequest ) (resp providers.PlanResourceChangeResponse ) {
4068+ // We're going to ignore any changes here and return the prior state.
4069+ resp .PlannedState = req .PriorState
4070+ return resp
4071+ }
4072+
4073+ state := states .NewState ()
4074+ root := state .RootModule ()
4075+ root .SetResourceInstanceCurrent (
4076+ mustResourceInstanceAddr ("test_object.a" ).Resource ,
4077+ & states.ResourceInstanceObjectSrc {
4078+ Status : states .ObjectReady ,
4079+ AttrsJSON : []byte (`{"map":{"prior":"value"}}` ),
4080+ Dependencies : []addrs.ConfigResource {},
4081+ },
4082+ mustProviderConfig (`provider["registry.terraform.io/hashicorp/test"]` ),
4083+ )
4084+ ctx := testContext2 (t , & ContextOpts {
4085+ Providers : map [addrs.Provider ]providers.Factory {
4086+ addrs .NewDefaultProvider ("test" ): testProviderFuncFixed (testProvider ),
4087+ },
4088+ })
4089+
4090+ // plan+apply to create the initial state
4091+ opts := SimplePlanOpts (plans .NormalMode , testInputValuesUnset (m .Module .Variables ))
4092+ plan , diags := ctx .Plan (m , state , opts )
4093+ assertNoErrors (t , diags )
4094+
4095+ for _ , c := range plan .Changes .Resources {
4096+ if c .Action != plans .NoOp {
4097+ t .Errorf ("unexpected %s change for %s" , c .Action , c .Addr )
4098+ }
4099+ }
4100+ }
0 commit comments