Skip to content

Commit

Permalink
Merge pull request #19488 from pascal236/r/aws_lambda_invocation
Browse files Browse the repository at this point in the history
New resource: aws_lambda_invocation
  • Loading branch information
YakDriver authored Jan 20, 2022
2 parents 2eeaefc + 19cc64d commit 14a8b6f
Show file tree
Hide file tree
Showing 23 changed files with 664 additions and 216 deletions.
3 changes: 3 additions & 0 deletions .changelog/19488.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
aws_lambda_invocation
```
1 change: 1 addition & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,7 @@ func Provider() *schema.Provider {
"aws_lambda_event_source_mapping": lambda.ResourceEventSourceMapping(),
"aws_lambda_function": lambda.ResourceFunction(),
"aws_lambda_function_event_invoke_config": lambda.ResourceFunctionEventInvokeConfig(),
"aws_lambda_invocation": lambda.ResourceInvocation(),
"aws_lambda_layer_version": lambda.ResourceLayerVersion(),
"aws_lambda_layer_version_permission": lambda.ResourceLayerVersionPermission(),
"aws_lambda_permission": lambda.ResourcePermission(),
Expand Down
8 changes: 4 additions & 4 deletions internal/service/lambda/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func resourceAliasCreate(d *schema.ResourceData, meta interface{}) error {
FunctionName: aws.String(functionName),
FunctionVersion: aws.String(d.Get("function_version").(string)),
Name: aws.String(aliasName),
RoutingConfig: expandLambdaAliasRoutingConfiguration(d.Get("routing_config").([]interface{})),
RoutingConfig: expandAliasRoutingConfiguration(d.Get("routing_config").([]interface{})),
}

aliasConfiguration, err := conn.CreateAlias(params)
Expand Down Expand Up @@ -131,7 +131,7 @@ func resourceAliasRead(d *schema.ResourceData, meta interface{}) error {
d.Set("arn", aliasConfiguration.AliasArn)
d.SetId(aws.StringValue(aliasConfiguration.AliasArn))

invokeArn := lambdaFunctionInvokeArn(*aliasConfiguration.AliasArn, meta)
invokeArn := functionInvokeArn(*aliasConfiguration.AliasArn, meta)
d.Set("invoke_arn", invokeArn)

if err := d.Set("routing_config", flattenAliasRoutingConfiguration(aliasConfiguration.RoutingConfig)); err != nil {
Expand Down Expand Up @@ -173,7 +173,7 @@ func resourceAliasUpdate(d *schema.ResourceData, meta interface{}) error {
FunctionName: aws.String(d.Get("function_name").(string)),
FunctionVersion: aws.String(d.Get("function_version").(string)),
Name: aws.String(d.Get("name").(string)),
RoutingConfig: expandLambdaAliasRoutingConfiguration(d.Get("routing_config").([]interface{})),
RoutingConfig: expandAliasRoutingConfiguration(d.Get("routing_config").([]interface{})),
}

_, err := conn.UpdateAlias(params)
Expand All @@ -184,7 +184,7 @@ func resourceAliasUpdate(d *schema.ResourceData, meta interface{}) error {
return nil
}

func expandLambdaAliasRoutingConfiguration(l []interface{}) *lambda.AliasRoutingConfiguration {
func expandAliasRoutingConfiguration(l []interface{}) *lambda.AliasRoutingConfiguration {
aliasRoutingConfiguration := &lambda.AliasRoutingConfiguration{}

if len(l) == 0 || l[0] == nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/service/lambda/alias_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func dataSourceAliasRead(d *schema.ResourceData, meta interface{}) error {
d.Set("description", aliasConfiguration.Description)
d.Set("function_version", aliasConfiguration.FunctionVersion)

invokeArn := lambdaFunctionInvokeArn(*aliasConfiguration.AliasArn, meta)
invokeArn := functionInvokeArn(*aliasConfiguration.AliasArn, meta)
d.Set("invoke_arn", invokeArn)

return nil
Expand Down
10 changes: 5 additions & 5 deletions internal/service/lambda/code_signing_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func resourceCodeSigningConfigCreate(d *schema.ResourceData, meta interface{}) e
log.Printf("[DEBUG] Creating Lambda code signing config")

configInput := &lambda.CreateCodeSigningConfigInput{
AllowedPublishers: expandLambdaCodeSigningConfigAllowedPublishers(d.Get("allowed_publishers").([]interface{})),
AllowedPublishers: expandCodeSigningConfigAllowedPublishers(d.Get("allowed_publishers").([]interface{})),
Description: aws.String(d.Get("description").(string)),
}

Expand Down Expand Up @@ -153,7 +153,7 @@ func resourceCodeSigningConfigRead(d *schema.ResourceData, meta interface{}) err
return fmt.Errorf("error setting lambda code signing config last modified: %s", err)
}

if err := d.Set("allowed_publishers", flattenLambdaCodeSigningConfigAllowedPublishers(codeSigningConfig.AllowedPublishers)); err != nil {
if err := d.Set("allowed_publishers", flattenCodeSigningConfigAllowedPublishers(codeSigningConfig.AllowedPublishers)); err != nil {
return fmt.Errorf("error setting lambda code signing config allowed publishers: %s", err)
}

Expand All @@ -173,7 +173,7 @@ func resourceCodeSigningConfigUpdate(d *schema.ResourceData, meta interface{}) e

configUpdate := false
if d.HasChange("allowed_publishers") {
configInput.AllowedPublishers = expandLambdaCodeSigningConfigAllowedPublishers(d.Get("allowed_publishers").([]interface{}))
configInput.AllowedPublishers = expandCodeSigningConfigAllowedPublishers(d.Get("allowed_publishers").([]interface{}))
configUpdate = true
}
if d.HasChange("policies") {
Expand Down Expand Up @@ -219,7 +219,7 @@ func resourceCodeSigningConfigDelete(d *schema.ResourceData, meta interface{}) e
return nil
}

func expandLambdaCodeSigningConfigAllowedPublishers(allowedPublishers []interface{}) *lambda.AllowedPublishers {
func expandCodeSigningConfigAllowedPublishers(allowedPublishers []interface{}) *lambda.AllowedPublishers {
if len(allowedPublishers) == 0 || allowedPublishers[0] == nil {
return nil
}
Expand All @@ -231,7 +231,7 @@ func expandLambdaCodeSigningConfigAllowedPublishers(allowedPublishers []interfac
}
}

func flattenLambdaCodeSigningConfigAllowedPublishers(allowedPublishers *lambda.AllowedPublishers) []interface{} {
func flattenCodeSigningConfigAllowedPublishers(allowedPublishers *lambda.AllowedPublishers) []interface{} {
if allowedPublishers == nil {
return []interface{}{}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/service/lambda/code_signing_config_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func dataSourceCodeSigningConfigRead(d *schema.ResourceData, meta interface{}) e
return fmt.Errorf("error setting lambda code signing config last modified: %w", err)
}

if err := d.Set("allowed_publishers", flattenLambdaCodeSigningConfigAllowedPublishers(codeSigningConfig.AllowedPublishers)); err != nil {
if err := d.Set("allowed_publishers", flattenCodeSigningConfigAllowedPublishers(codeSigningConfig.AllowedPublishers)); err != nil {
return fmt.Errorf("error setting lambda code signing config allowed publishers: %w", err)
}

Expand Down
Loading

0 comments on commit 14a8b6f

Please sign in to comment.