@@ -124,7 +124,7 @@ func resourceInventorySourceCreate(ctx context.Context, d *schema.ResourceData,
124124 client := m .(* awx.AWX )
125125 awxService := client .InventorySourcesService
126126
127- result , err := awxService . CreateInventorySource ( map [string ]interface {}{
127+ createInventorySourceData := map [string ]interface {}{
128128 "name" : d .Get ("name" ).(string ),
129129 "description" : d .Get ("description" ).(string ),
130130 "enabled_var" : d .Get ("enabled_var" ).(string ),
@@ -133,7 +133,6 @@ func resourceInventorySourceCreate(ctx context.Context, d *schema.ResourceData,
133133 "overwrite_vars" : d .Get ("overwrite_vars" ).(bool ),
134134 "update_on_launch" : d .Get ("update_on_launch" ).(bool ),
135135 "inventory" : d .Get ("inventory_id" ).(int ),
136- "credential" : d .Get ("credential_id" ).(int ),
137136 "source" : d .Get ("source" ).(string ),
138137 "source_vars" : d .Get ("source_vars" ).(string ),
139138 "host_filter" : d .Get ("host_filter" ).(string ),
@@ -146,7 +145,12 @@ func resourceInventorySourceCreate(ctx context.Context, d *schema.ResourceData,
146145 "group_by" : d .Get ("group_by" ).(string ),
147146 "source_project" : d .Get ("source_project_id" ).(int ),
148147 "source_path" : d .Get ("source_path" ).(string ),
149- }, map [string ]string {})
148+ }
149+ if _ , ok := d .GetOk ("credential_id" ); ok {
150+ createInventorySourceData ["credential" ] = d .Get ("credential_id" ).(int )
151+ }
152+
153+ result , err := awxService .CreateInventorySource (createInventorySourceData , map [string ]string {})
150154 if err != nil {
151155 return buildDiagCreateFail (diagElementInventorySourceTitle , err )
152156 }
0 commit comments