@@ -26,15 +26,10 @@ func resourceAwsKmsKey() *schema.Resource {
2626 Type : schema .TypeString ,
2727 Computed : true ,
2828 },
29- "enabled" : & schema.Schema {
30- Type : schema .TypeBool ,
31- Computed : true ,
32- },
3329 "description" : & schema.Schema {
3430 Type : schema .TypeString ,
3531 Optional : true ,
3632 Computed : true ,
37- ForceNew : false ,
3833 },
3934 "key_usage" : & schema.Schema {
4035 Type : schema .TypeString ,
@@ -54,7 +49,18 @@ func resourceAwsKmsKey() *schema.Resource {
5449 Type : schema .TypeString ,
5550 Optional : true ,
5651 Computed : true ,
57- ForceNew : false ,
52+ },
53+ "deletion_window" : & schema.Schema {
54+ Type : schema .TypeInt ,
55+ Optional : true ,
56+ ValidateFunc : func (v interface {}, k string ) (ws []string , es []error ) {
57+ value := v .(int )
58+ if (value > 30 || value < 7 ) {
59+ es = append (es , fmt .Errorf (
60+ "deletion window must be between 7 and 30 days inclusive" ))
61+ }
62+ return
63+ },
5864 },
5965 },
6066 }
@@ -87,7 +93,7 @@ func resourceAwsKmsKeyRead(d *schema.ResourceData, meta interface{}) error {
8793 keyId := d .Get ("key_id" ).(string )
8894
8995 req := & kms.DescribeKeyInput {
90- KeyId : aws .String (keyId ),
96+ KeyId : aws .String (keyId ),
9197 }
9298 resp , err := conn .DescribeKey (req )
9399 if err != nil {
@@ -105,9 +111,6 @@ func resourceAwsKmsKeyReadResult(d *schema.ResourceData, metadata *kms.KeyMetada
105111 if err := d .Set ("key_id" , metadata .KeyId ); err != nil {
106112 return err
107113 }
108- if err := d .Set ("enabled" , metadata .Enabled ); err != nil {
109- return err
110- }
111114 if err := d .Set ("description" , metadata .Description ); err != nil {
112115 return err
113116 }
@@ -166,10 +169,13 @@ func resourceAwsKmsKeyDelete(d *schema.ResourceData, meta interface{}) error {
166169 conn := meta .(* AWSClient ).kmsconn
167170 keyId := d .Get ("key_id" ).(string )
168171
169- req := & kms.DisableKeyInput {
170- KeyId : aws .String (keyId ),
172+ req := & kms.ScheduleKeyDeletionInput {
173+ KeyId : aws .String (keyId ),
174+ }
175+ if v , exists := d .GetOk ("deletion_window" ); exists {
176+ req .PendingWindowInDays = aws .Int64 (int64 (v .(int )))
171177 }
172- _ , err := conn .DisableKey (req )
178+ _ , err := conn .ScheduleKeyDeletion (req )
173179
174180 log .Printf ("[DEBUG] KMS Key: %s deactivated." , keyId )
175181 d .SetId ("" )
0 commit comments