@@ -35,6 +35,12 @@ func Provider() *schema.Provider {
3535 Sensitive : true ,
3636 DefaultFunc : schema .EnvDefaultFunc ("AWX_PASSWORD" , "password" ),
3737 },
38+ "token" : {
39+ Type : schema .TypeString ,
40+ Optional : true ,
41+ Sensitive : true ,
42+ DefaultFunc : schema .EnvDefaultFunc ("AWX_TOKEN" , "" ),
43+ },
3844 },
3945 ResourcesMap : map [string ]* schema.Resource {
4046 "awx_credential_azure_key_vault" : resourceCredentialAzureKeyVault (),
@@ -98,6 +104,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}
98104 hostname := d .Get ("hostname" ).(string )
99105 username := d .Get ("username" ).(string )
100106 password := d .Get ("password" ).(string )
107+ token := d .Get ("token" ).(string )
101108
102109 // Warning or errors can be collected in a slice type
103110 var diags diag.Diagnostics
@@ -109,7 +116,13 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}
109116 client .Transport = customTransport
110117 }
111118
112- c , err := awx .NewAWX (hostname , username , password , client )
119+ var c * awx.AWX
120+ var err error
121+ if token != "" {
122+ c , err = awx .NewAWXToken (hostname , token , client )
123+ } else {
124+ c , err = awx .NewAWX (hostname , username , password , client )
125+ }
113126 if err != nil {
114127 diags = append (diags , diag.Diagnostic {
115128 Severity : diag .Error ,
0 commit comments