-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(IAM): import IAM resource, unit test and document.
- Loading branch information
1 parent
f1b8d5f
commit 388384d
Showing
3 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# flexibleengine_account | ||
|
||
Use this data source to get information about the current account. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
data "flexibleengine_account" "current" {} | ||
output "current_account_id" { | ||
value = data.flexibleengine_account.current.id | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
There are no arguments available for this data source. | ||
|
||
## Attribute Reference | ||
|
||
In addition to all arguments above, the following attributes are exported: | ||
|
||
* `id` - The account ID. | ||
|
||
* `name` - The account name. |
46 changes: 46 additions & 0 deletions
46
flexibleengine/acceptance/data_source_flexibleengine_account_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package acceptance | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform" | ||
) | ||
|
||
func TestAccDatasourceAccount_basic(t *testing.T) { | ||
rName := "data.flexibleengine_account.current" | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
ProviderFactories: TestAccProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDatasourceAccount_basic, | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAccountDataSourceID(rName), | ||
resource.TestCheckResourceAttrSet(rName, "name"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCheckAccountDataSourceID(n string) resource.TestCheckFunc { | ||
return func(s *terraform.State) error { | ||
rs, ok := s.RootModule().Resources[n] | ||
if !ok { | ||
return fmt.Errorf("Can't find the account data source: %s ", n) | ||
} | ||
|
||
if rs.Primary.ID == "" { | ||
return fmt.Errorf("the account data source ID not set") | ||
} | ||
|
||
return nil | ||
} | ||
} | ||
|
||
const testAccDatasourceAccount_basic = ` | ||
data "flexibleengine_account" "current" {} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters