Generate valid Permission names for aws.serverless.API

The previous checkin exposed some validation
errors that had previously been surpressed,
including an error validating the Permission
statementId's generated by aws.serverless.API.
This commit is contained in:
Luke Hoban 2017-06-07 16:34:17 -07:00
parent 73e4be9f5e
commit 96c25a9614
2 changed files with 1 additions and 3 deletions

View file

@ -119,7 +119,7 @@ export class API {
if(this.api.apiName !== undefined) {
apiName = this.api.apiName;
}
let invokePermission = new Permission(this.apiName + "_invoke_" + method + path, {
let invokePermission = new Permission(this.apiName + "_invoke_" + sha1hash(method + path), {
action: "lambda:invokeFunction",
function: lambda.lambda,
principal: "apigateway.amazonaws.com",

View file

@ -109,7 +109,6 @@ type permissionProvider struct {
// Check validates that the given property bag is valid for a resource of the given type.
func (p *permissionProvider) Check(ctx context.Context, obj *lambda.Permission) ([]error, error) {
var failures []error
fmt.Printf("Check: %v\n", obj)
if matched, err := regexp.MatchString(actionRegexp, obj.Action); err != nil || !matched {
failures = append(failures,
resource.NewFieldError(reflect.TypeOf(obj), lambda.Permission_Action,
@ -130,7 +129,6 @@ func (p *permissionProvider) Check(ctx context.Context, obj *lambda.Permission)
fmt.Errorf("did not match regexp %v", sourceARNRegexp)))
}
}
fmt.Printf("# failures: %v\n", len(failures))
return failures, nil
}