|
6 | 6 |
|
7 | 7 | "github.com/databrickslabs/terraform-provider-databricks/common" |
8 | 8 |
|
| 9 | + "github.com/hashicorp/go-cty/cty" |
9 | 10 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" |
10 | 11 | ) |
11 | 12 |
|
@@ -104,6 +105,60 @@ func ResourceCustomerManagedKey() *schema.Resource { |
104 | 105 | } |
105 | 106 | return NewCustomerManagedKeysAPI(ctx, c).Delete(accountID, cmkID) |
106 | 107 | }, |
107 | | - Schema: s, |
| 108 | + Schema: s, |
| 109 | + SchemaVersion: 1, |
| 110 | + StateUpgraders: []schema.StateUpgrader{ |
| 111 | + { |
| 112 | + Version: 0, |
| 113 | + Type: ResourceCustomerManagedKeyV0(), |
| 114 | + Upgrade: migrateResourceCustomerManagedKeyV0, |
| 115 | + }, |
| 116 | + }, |
108 | 117 | }.ToResource() |
109 | 118 | } |
| 119 | + |
| 120 | +func migrateResourceCustomerManagedKeyV0(ctx context.Context, |
| 121 | + rawState map[string]interface{}, |
| 122 | + meta interface{}) (map[string]interface{}, error) { |
| 123 | + rawState["use_cases"] = []string{"MANAGED_SERVICES"} |
| 124 | + return rawState, nil |
| 125 | +} |
| 126 | + |
| 127 | +func ResourceCustomerManagedKeyV0() cty.Type { |
| 128 | + return (&schema.Resource{ |
| 129 | + Schema: map[string]*schema.Schema{ |
| 130 | + "account_id": { |
| 131 | + Type: schema.TypeString, |
| 132 | + ForceNew: true, |
| 133 | + }, |
| 134 | + "customer_managed_key_id": { |
| 135 | + Type: schema.TypeString, |
| 136 | + Optional: true, |
| 137 | + Computed: true, |
| 138 | + }, |
| 139 | + "creation_time": { |
| 140 | + Type: schema.TypeInt, |
| 141 | + Computed: true, |
| 142 | + }, |
| 143 | + "aws_key_info": { |
| 144 | + Type: schema.TypeList, |
| 145 | + ForceNew: true, |
| 146 | + Elem: &schema.Resource{ |
| 147 | + Schema: map[string]*schema.Schema{ |
| 148 | + "key_arn": { |
| 149 | + Type: schema.TypeString, |
| 150 | + }, |
| 151 | + "key_alias": { |
| 152 | + Type: schema.TypeString, |
| 153 | + }, |
| 154 | + "key_region": { |
| 155 | + Type: schema.TypeString, |
| 156 | + Optional: true, |
| 157 | + Computed: true, |
| 158 | + }, |
| 159 | + }, |
| 160 | + }, |
| 161 | + }, |
| 162 | + }, |
| 163 | + }).CoreConfigSchema().ImpliedType() |
| 164 | +} |
0 commit comments