Skip to content

Commit

Permalink
feat: support comment property for athena databases
Browse files Browse the repository at this point in the history
  • Loading branch information
drexler committed Dec 2, 2021
1 parent 3b1304d commit 02adf61
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion internal/service/athena/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ func ResourceDatabase() *schema.Resource {
Required: true,
ForceNew: true,
},
"comment": {
Type: schema.TypeString,
Optional: true,
},
"force_destroy": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -93,8 +97,15 @@ func expandAthenaResultConfiguration(bucket string, encryptionConfigurationList
func resourceDatabaseCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*conns.AWSClient).AthenaConn

var databaseDescription string
if v, ok := d.GetOk("comment"); ok {
databaseDescription = strings.Replace(v.(string), "'", "\\'", -1)
} else {
databaseDescription = ""
}

input := &athena.StartQueryExecutionInput{
QueryString: aws.String(fmt.Sprintf("create database `%s`;", d.Get("name").(string))),
QueryString: aws.String(fmt.Sprintf("create database `%[1]s` comment '%[2]s';", d.Get("name").(string), databaseDescription)),
ResultConfiguration: expandAthenaResultConfiguration(d.Get("bucket").(string), d.Get("encryption_configuration").([]interface{})),
}

Expand Down

0 comments on commit 02adf61

Please sign in to comment.