Skip to content

Commit

Permalink
Merge pull request #60 from spring-media/fix/remove-unused-code
Browse files Browse the repository at this point in the history
Fix/remove unused code
  • Loading branch information
thatsddr authored May 31, 2022
2 parents b0e7ca8 + 94dd2f8 commit 6cc28a2
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 113 deletions.
13 changes: 0 additions & 13 deletions awsmt/data_source_source_location.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,6 @@ func dataSourceSourceLocation() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceSourceLocationRead,
Schema: map[string]*schema.Schema{
"access_configuration": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"access_type": &computedString,
// SMATC is short for Secret Manager Access Token Configuration
"smatc_header_name": &computedString,
"smatc_secret_arn": &computedString,
"smatc_secret_string_key": &computedString,
},
},
},
"arn": &computedString,
"creation_time": &computedString,
"default_segment_delivery_configuration_url": &computedString,
Expand Down
3 changes: 0 additions & 3 deletions awsmt/data_source_source_location_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ func TestAccSourceLocationDataSourceBasic(t *testing.T) {
func testAccSourceLocationDataSourceBasic(rName string) string {
return fmt.Sprintf(`
resource "awsmt_source_location" "test_data_source"{
access_configuration {
access_type = "S3_SIGV4"
}
default_segment_delivery_configuration_url = "https://www.example.com"
http_configuration_url = "https://ott-mediatailor-test.s3.eu-central-1.amazonaws.com/test-img.jpeg"
source_location_name = "%[1]s"
Expand Down
20 changes: 0 additions & 20 deletions awsmt/resource_source_location.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"strings"
)

Expand All @@ -26,25 +25,6 @@ func resourceSourceLocation() *schema.Resource {
customdiff.ForceNewIfChange("source_location_name", func(ctx context.Context, old, new, meta interface{}) bool { return old.(string) != new.(string) }),
),
Schema: map[string]*schema.Schema{
"access_configuration": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
//may require s3:GetObject
"access_type": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"S3_SIGV4", "SECRETS_MANAGER_ACCESS_TOKEN"}, false),
},
// SMATC is short for Secrets Manager Access Token Configuration
"smatc_header_name": &optionalString,
"smatc_secret_arn": &optionalString,
"smatc_secret_string_key": &optionalString,
},
},
},
"arn": &computedString,
"creation_time": &computedString,
"default_segment_delivery_configuration_url": &optionalString,
Expand Down
3 changes: 0 additions & 3 deletions awsmt/resource_source_location_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,6 @@ resource "awsmt_source_location" "test"{
func testAccSourceLocationConfig_update(rName, exampleString, exampleUrl, baseUrl string) string {
return fmt.Sprintf(`
resource "awsmt_source_location" "test_update"{
access_configuration {
access_type = "S3_SIGV4"
}
default_segment_delivery_configuration_url = "%[3]s"
http_configuration_url = "%[4]s"
source_location_name = "%[1]s"
Expand Down
64 changes: 0 additions & 64 deletions awsmt/source_location_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func setAccessConfiguration(values *mediatailor.DescribeSourceLocationOutput, d *schema.ResourceData) error {
if values.AccessConfiguration != nil && values.AccessConfiguration != &(mediatailor.AccessConfiguration{}) {
temp := map[string]interface{}{}
if values.AccessConfiguration.AccessType != nil {
temp["access_type"] = values.AccessConfiguration.AccessType
}
if values.AccessConfiguration.SecretsManagerAccessTokenConfiguration != nil && values.AccessConfiguration.SecretsManagerAccessTokenConfiguration != &(mediatailor.SecretsManagerAccessTokenConfiguration{}) {
if values.AccessConfiguration.SecretsManagerAccessTokenConfiguration.HeaderName != nil {
temp["smatc_header_name"] = values.AccessConfiguration.SecretsManagerAccessTokenConfiguration.HeaderName
}
if values.AccessConfiguration.SecretsManagerAccessTokenConfiguration.SecretArn != nil {
temp["smatc_secret_arn"] = values.AccessConfiguration.SecretsManagerAccessTokenConfiguration.SecretArn
}
if values.AccessConfiguration.SecretsManagerAccessTokenConfiguration.SecretStringKey != nil {
temp["smatc_secret_string_key"] = values.AccessConfiguration.SecretsManagerAccessTokenConfiguration.SecretStringKey
}
}
if err := d.Set("access_configuration", []interface{}{temp}); err != nil {
return fmt.Errorf("error while setting the access configuration: %w", err)
}
}
return nil
}

func setSegmentDeliveryConfigurations(values *mediatailor.DescribeSourceLocationOutput, d *schema.ResourceData) error {
var configurations []map[string]interface{}
for _, c := range values.SegmentDeliveryConfigurations {
Expand All @@ -48,7 +24,6 @@ func setSegmentDeliveryConfigurations(values *mediatailor.DescribeSourceLocation
func setSourceLocation(values *mediatailor.DescribeSourceLocationOutput, d *schema.ResourceData) error {
var errors []error

errors = append(errors, setAccessConfiguration(values, d))
errors = append(errors, d.Set("arn", values.Arn))
errors = append(errors, d.Set("creation_time", values.CreationTime.String()))
if values.DefaultSegmentDeliveryConfiguration != nil && values.DefaultSegmentDeliveryConfiguration != &(mediatailor.DefaultSegmentDeliveryConfiguration{}) {
Expand All @@ -73,37 +48,6 @@ func setSourceLocation(values *mediatailor.DescribeSourceLocationOutput, d *sche
return nil
}

func getAccessConfiguration(d *schema.ResourceData) *mediatailor.AccessConfiguration {
if v, ok := d.GetOk("access_configuration"); ok && v.([]interface{})[0] != nil {
val := v.([]interface{})[0].(map[string]interface{})
temp := mediatailor.AccessConfiguration{}
var accessType string
if v, ok := val["access_type"]; ok {
temp.AccessType = aws.String(v.(string))
accessType = v.(string)
}

tempSMATC := mediatailor.SecretsManagerAccessTokenConfiguration{}
if str, ok := val["smatc_header_name"]; ok {
tempSMATC.HeaderName = aws.String(str.(string))
}
if str, ok := val["smatc_secret_arn"]; ok {
tempSMATC.SecretArn = aws.String(str.(string))
}
if str, ok := val["smatc_secret_arn"]; ok {
tempSMATC.SecretArn = aws.String(str.(string))
}
if str, ok := val["smatc_secret_string_key"]; ok {
tempSMATC.SecretStringKey = aws.String(str.(string))
}
if tempSMATC != (mediatailor.SecretsManagerAccessTokenConfiguration{}) && accessType == "SECRETS_MANAGER_ACCESS_TOKEN" {
temp.SecretsManagerAccessTokenConfiguration = &tempSMATC
}
return &temp
}
return nil
}

func getSegmentDeliveryConfigurations(d *schema.ResourceData) []*mediatailor.SegmentDeliveryConfiguration {
if v, ok := d.GetOk("segment_delivery_configurations"); ok && v.([]interface{})[0] != nil {
configurations := v.([]interface{})
Expand All @@ -130,10 +74,6 @@ func getSegmentDeliveryConfigurations(d *schema.ResourceData) []*mediatailor.Seg
func getCreateSourceLocationInput(d *schema.ResourceData) mediatailor.CreateSourceLocationInput {
var inputParams mediatailor.CreateSourceLocationInput

if a := getAccessConfiguration(d); a != nil {
inputParams.AccessConfiguration = a
}

if v, ok := d.GetOk("default_segment_delivery_configuration_url"); ok {
inputParams.DefaultSegmentDeliveryConfiguration = &mediatailor.DefaultSegmentDeliveryConfiguration{BaseUrl: aws.String(v.(string))}
}
Expand Down Expand Up @@ -167,10 +107,6 @@ func getCreateSourceLocationInput(d *schema.ResourceData) mediatailor.CreateSour
func getUpdateSourceLocationInput(d *schema.ResourceData) mediatailor.UpdateSourceLocationInput {
var updateParams mediatailor.UpdateSourceLocationInput

if a := getAccessConfiguration(d); a != nil {
updateParams.AccessConfiguration = a
}

if v, ok := d.GetOk("default_segment_delivery_configuration_url"); ok {
updateParams.DefaultSegmentDeliveryConfiguration = &mediatailor.DefaultSegmentDeliveryConfiguration{BaseUrl: aws.String(v.(string))}
}
Expand Down
11 changes: 2 additions & 9 deletions docs/data-sources/awsmt_source_location.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

This data source provides information about a MediaTailor Source Location.

~> **NOTE:** The source location data source currently does not support the use of access configuration using Amazon Secrets Manager Access Token.

## Example Usage

```terraform
Expand All @@ -26,15 +28,6 @@ In addition to all arguments above, the following attributes are exported:
* `last_modified_time` - The timestamp of when the channel was last modified.
* `tags` - Key-value mapping of resource tags.


### `access_configuration`
Access configuration parameters. Configures the type of authentication used to access content from your source location.

* `access_type` - The type of authentication used to access content from HttpConfiguration::BaseUrl on your source location. Accepted values: "S3_SIGV4" and "SECRETS_MANAGER_ACCESS_TOKEN". [Read More](https://docs.aws.amazon.com/sdk-for-go/api/service/mediatailor/#AccessConfiguration).
* `smatc_header_name` - Part of Secrets Manager Access Token Configuration. The name of the HTTP header used to supply the access token in requests to the source location.
* `smatc_secret_arn` - Part of Secrets Manager Access Token Configuration. The Amazon Resource Name (ARN) of the AWS Secrets Manager secret that contains the access token.
* `smatc_secret_string_key` - Part of Secrets Manager Access Token Configuration. The AWS Secrets Manager SecretString key associated with the access token.

### `segment_delivery_configurations`
(List) A list of the segment delivery configurations associated with this resource.

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Example configuration (using Terraform 0.13 or newer):
terraform {
required_providers {
awsmt = {
version = "1.13.0"
version = "1.14.1"
source = "spring-media/awsmt"
}
}
Expand Down
2 changes: 2 additions & 0 deletions docs/resources/awsmt_source_location.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Use this resource to manage a MediaTailor Source Location.

~> **NOTE:** The source location data source currently does not support the use of access configuration using Amazon Secrets Manager Access Token.

## Example Usage

```terraform
Expand Down

0 comments on commit 6cc28a2

Please sign in to comment.