Issue an error for missing property names

This commit is contained in:
joeduffy 2016-12-05 15:18:04 -08:00
parent a82a49291b
commit 069342fef6
6 changed files with 22 additions and 11 deletions

View file

@ -71,9 +71,9 @@ services:
DestinationCidrBlock: destinationCidrBlock
RouteTableId: routeTable
InternetGatewayId: internetGateway
VpnGatewayId: vpnGateway
InstanceId: instance
NatGatewayId: natGateway
NetworkInterfaceId: networkInterface
VpcPeeringConnectionId: vpcPeeringConnection
#VpnGatewayId: vpnGateway
#InstanceId: instance
#NatGatewayId: natGateway
#NetworkInterfaceId: networkInterface
#VpcPeeringConnectionId: vpcPeeringConnection

View file

@ -22,7 +22,7 @@ services:
resource: "AWS::EC2::RouteTable"
properties:
VpcId: vpc
Tags: tag
Tags: tags
{{if has .Properties "name" -}}
extraProperties:
Tags:

View file

@ -42,8 +42,7 @@ services:
CidrBlock: cidrBlock
EnableDnsSupport: enableDnsSupport
InstanceTenancy: instanceTenancy
EnableDnsHostnames: EnableDnsHostnames
InstanceTenancy: instanceTenancy
EnableDnsHostnames: enableDnsHostnames
Tags: tags
{{if has .Properties "name" -}}
extraProperties:

View file

@ -27,5 +27,5 @@ services:
properties:
VpcId: vpc
InternetGatewayId: internetGateway
VpnGatewayId: vpnGateway
#VpnGatewayId: vpnGateway

View file

@ -309,6 +309,13 @@ func (c *awsCloud) genCFIntrinsicServiceTemplate(comp core.Compiland, stack *ast
from := cf.Properties.StringStringMap[to]
if p, has := stack.BoundPropertyValues[from]; has {
resProps[to] = c.propertyLiteralToValue(p)
} else {
// It's ok if there is no bound property for this; that just means the caller didn't supply a value, which
// is totally legal for optional properties. But at least make sure the property refers to a valid property
// name, otherwise this could be a mistake (mispelled name, etc).
if _, has := stack.Properties[from]; !has {
c.Diag().Errorf(ErrorPropertyNotFound.At(stack), from)
}
}
}

View file

@ -13,7 +13,12 @@ var ErrorMarshalingCloudFormationTemplate = &diag.Diag{
Message: "An error occurred when marshaling the output AWS CloudFormation template: %v",
}
var ErrorDuplicateExtraProperty = &diag.Diag{
var ErrorPropertyNotFound = &diag.Diag{
ID: 10001,
Message: "Extra property %v conflicts with an existing auto-mapped property; did you mean to use skipProperties?",
Message: "Property %v was not found within this stack",
}
var ErrorDuplicateExtraProperty = &diag.Diag{
ID: 10002,
Message: "Extra property %v conflicts with an existing mapped property",
}