@@ -10,6 +10,8 @@ import (
1010
1111 "github.com/aws/aws-sdk-go/aws"
1212 "github.com/aws/aws-sdk-go/service/codepipeline"
13+ "github.com/hashicorp/go-cty/cty"
14+ "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1315 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
1416 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1517 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
@@ -59,11 +61,9 @@ func resourceAwsCodePipeline() *schema.Resource {
5961 Required : true ,
6062 },
6163 "type" : {
62- Type : schema .TypeString ,
63- Required : true ,
64- ValidateFunc : validation .StringInSlice ([]string {
65- codepipeline .ArtifactStoreTypeS3 ,
66- }, false ),
64+ Type : schema .TypeString ,
65+ Required : true ,
66+ ValidateFunc : validation .StringInSlice (codepipeline .ArtifactStoreType_Values (), false ),
6767 },
6868 "encryption_key" : {
6969 Type : schema .TypeList ,
@@ -76,11 +76,9 @@ func resourceAwsCodePipeline() *schema.Resource {
7676 Required : true ,
7777 },
7878 "type" : {
79- Type : schema .TypeString ,
80- Required : true ,
81- ValidateFunc : validation .StringInSlice ([]string {
82- codepipeline .EncryptionKeyTypeKms ,
83- }, false ),
79+ Type : schema .TypeString ,
80+ Required : true ,
81+ ValidateFunc : validation .StringInSlice (codepipeline .EncryptionKeyType_Values (), false ),
8482 },
8583 },
8684 },
@@ -115,29 +113,19 @@ func resourceAwsCodePipeline() *schema.Resource {
115113 DiffSuppressFunc : suppressCodePipelineStageActionConfiguration ,
116114 },
117115 "category" : {
118- Type : schema .TypeString ,
119- Required : true ,
120- ValidateFunc : validation .StringInSlice ([]string {
121- codepipeline .ActionCategorySource ,
122- codepipeline .ActionCategoryBuild ,
123- codepipeline .ActionCategoryDeploy ,
124- codepipeline .ActionCategoryTest ,
125- codepipeline .ActionCategoryInvoke ,
126- codepipeline .ActionCategoryApproval ,
127- }, false ),
116+ Type : schema .TypeString ,
117+ Required : true ,
118+ ValidateFunc : validation .StringInSlice (codepipeline .ActionCategory_Values (), false ),
128119 },
129120 "owner" : {
130- Type : schema .TypeString ,
131- Required : true ,
132- ValidateFunc : validation .StringInSlice ([]string {
133- codepipeline .ActionOwnerAws ,
134- codepipeline .ActionOwnerThirdParty ,
135- codepipeline .ActionOwnerCustom ,
136- }, false ),
121+ Type : schema .TypeString ,
122+ Required : true ,
123+ ValidateFunc : validation .StringInSlice (codepipeline .ActionOwner_Values (), false ),
137124 },
138125 "provider" : {
139- Type : schema .TypeString ,
140- Required : true ,
126+ Type : schema .TypeString ,
127+ Required : true ,
128+ ValidateDiagFunc : resourceAwsCodePipelineValidateActionProvider ,
141129 },
142130 "version" : {
143131 Type : schema .TypeString ,
@@ -425,8 +413,7 @@ func flattenAwsCodePipelineStageActions(si int, actions []*codepipeline.ActionDe
425413 if _ , ok := config [CodePipelineGitHubActionConfigurationOAuthToken ]; ok {
426414 // The AWS API returns "****" for the OAuthToken value. Pull the value from the configuration.
427415 addr := fmt .Sprintf ("stage.%d.action.%d.configuration.OAuthToken" , si , ai )
428- hash := hashCodePipelineGitHubToken (d .Get (addr ).(string ))
429- config [CodePipelineGitHubActionConfigurationOAuthToken ] = hash
416+ config [CodePipelineGitHubActionConfigurationOAuthToken ] = d .Get (addr ).(string )
430417 }
431418 }
432419
@@ -620,6 +607,25 @@ func resourceAwsCodePipelineDelete(d *schema.ResourceData, meta interface{}) err
620607 return err
621608}
622609
610+ func resourceAwsCodePipelineValidateActionProvider (i interface {}, path cty.Path ) diag.Diagnostics {
611+ v , ok := i .(string )
612+ if ! ok {
613+ return diag .Errorf ("expected type to be string" )
614+ }
615+
616+ if v == CodePipelineProviderGitHub {
617+ return diag.Diagnostics {
618+ diag.Diagnostic {
619+ Severity : diag .Warning ,
620+ Summary : "The CodePipeline GitHub version 1 action provider is deprecated." ,
621+ Detail : "Use a GitHub version 2 action (with a CodeStar Connection `aws_codestarconnections_connection`) instead. See https://docs.aws.amazon.com/codepipeline/latest/userguide/update-github-action-connections.html" ,
622+ },
623+ }
624+ }
625+
626+ return nil
627+ }
628+
623629func suppressCodePipelineStageActionConfiguration (k , old , new string , d * schema.ResourceData ) bool {
624630 parts := strings .Split (k , "." )
625631 parts = parts [:len (parts )- 2 ]
0 commit comments