-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reimplement "mackerel_aws_integration" data source with terraform-plugin-framework #247
Conversation
Name types.String `tfsdk:"name"` | ||
Memo types.String `tfsdk:"memo"` | ||
Key types.String `tfsdk:"key"` | ||
SecretKey types.String `tfsdk:"-"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AWS Integration resources contain an AWS secret key in their state, whereas data sources do not.
attrs := map[string]schema.Attribute{ | ||
"id": schema.StringAttribute{ | ||
Description: schemaAWSIntegrationIDDesc, | ||
Required: true, | ||
}, | ||
"name": schema.StringAttribute{ | ||
Description: schemaAWSIntegrationNameDesc, | ||
Computed: true, | ||
}, | ||
"memo": schema.StringAttribute{ | ||
Description: schemaAWSIntegrationMemoDesc, | ||
Computed: true, | ||
}, | ||
"key": schema.StringAttribute{ | ||
Description: schemaAWSIntegrationKeyDesc, | ||
Computed: true, | ||
}, | ||
"role_arn": schema.StringAttribute{ | ||
Description: schemaAWSIntegrationRoleARNDesc, | ||
Computed: true, | ||
}, | ||
"external_id": schema.StringAttribute{ | ||
Description: schemaAWSIntegrationExternalIDDesc, | ||
Computed: true, | ||
}, | ||
"region": schema.StringAttribute{ | ||
Description: schemaAWSIntegrationRegionDesc, | ||
Computed: true, | ||
}, | ||
"included_tags": schema.StringAttribute{ | ||
Description: schemaAWSIntegrationIncludedTagsDesc, | ||
Computed: true, | ||
}, | ||
"excluded_tags": schema.StringAttribute{ | ||
Description: schemaAWSIntegrationExcludedTagsDesc, | ||
Computed: true, | ||
}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Original schema:
terraform-provider-mackerel/mackerel/data_source_mackerel_aws_integration.go
Lines 70 to 108 in 0f86842
Schema: map[string]*schema.Schema{ | |
"id": { | |
Type: schema.TypeString, | |
Required: true, | |
}, | |
"name": { | |
Type: schema.TypeString, | |
Computed: true, | |
}, | |
"memo": { | |
Type: schema.TypeString, | |
Computed: true, | |
}, | |
"key": { | |
Type: schema.TypeString, | |
Computed: true, | |
}, | |
"role_arn": { | |
Type: schema.TypeString, | |
Computed: true, | |
}, | |
"external_id": { | |
Type: schema.TypeString, | |
Computed: true, | |
Sensitive: true, | |
}, | |
"region": { | |
Type: schema.TypeString, | |
Computed: true, | |
}, | |
"included_tags": { | |
Type: schema.TypeString, | |
Computed: true, | |
}, | |
"excluded_tags": { | |
Type: schema.TypeString, | |
Computed: true, | |
}, | |
}, |
if spec.supportsAutoRetire { | ||
attrs[name] = schema.SetAttribute{ | ||
Computed: true, | ||
ElementType: types.ObjectType{ | ||
AttrTypes: map[string]attr.Type{ | ||
"enable": types.BoolType, | ||
"role": types.StringType, | ||
"excluded_metrics": types.ListType{ | ||
ElemType: types.StringType, | ||
}, | ||
"retire_automatically": types.BoolType, | ||
}, | ||
}, | ||
} | ||
} else { | ||
attrs[name] = schema.SetAttribute{ | ||
Computed: true, | ||
ElementType: types.ObjectType{ | ||
AttrTypes: map[string]attr.Type{ | ||
"enable": types.BoolType, | ||
"role": types.StringType, | ||
"excluded_metrics": types.ListType{ | ||
ElemType: types.StringType, | ||
}, | ||
}, | ||
}, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Original schema:
terraform-provider-mackerel/mackerel/data_source_mackerel_aws_integration.go
Lines 11 to 59 in 0f86842
var awsIntegrationServiceDataResourceWithRetireAutomatically = &schema.Resource{ | |
Schema: map[string]*schema.Schema{ | |
"enable": { | |
Type: schema.TypeBool, | |
Computed: true, | |
}, | |
"role": { | |
Type: schema.TypeString, | |
Computed: true, | |
}, | |
"excluded_metrics": { | |
Type: schema.TypeList, | |
Computed: true, | |
Elem: &schema.Schema{ | |
Type: schema.TypeString, | |
}, | |
}, | |
"retire_automatically": { | |
Type: schema.TypeBool, | |
Computed: true, | |
}, | |
}, | |
} | |
var awsIntegrationServiceDataSchemaWithRetireAutomatically = &schema.Schema{ | |
Type: schema.TypeSet, | |
Computed: true, | |
Elem: awsIntegrationServiceDataResourceWithRetireAutomatically, | |
} | |
var awsIntegrationServiceDataResource = &schema.Resource{ | |
Schema: map[string]*schema.Schema{ | |
"enable": { | |
Type: schema.TypeBool, | |
Computed: true, | |
}, | |
"role": { | |
Type: schema.TypeString, | |
Computed: true, | |
}, | |
"excluded_metrics": { | |
Type: schema.TypeList, | |
Computed: true, | |
Elem: &schema.Schema{ | |
Type: schema.TypeString, | |
}, | |
}, | |
}, | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM!
Part of #243 . This PR adds a new "mackerel_aws_integration" data source implementation using
AWSIntegrationModel
introduced in #244 .Output from acceptance testing: