mirror of https://github.com/kubernetes/kops.git
fix cloudformation verify
This commit is contained in:
parent
318a116ba6
commit
fb3f317e42
|
@ -916,7 +916,14 @@
|
|||
"Type": "AWS::Events::Rule",
|
||||
"Properties": {
|
||||
"Name": "queueprocessor.example.com-ASGLifecycle",
|
||||
"EventPattern": "{"source":["aws.autoscaling"],"detail-type":["EC2 Instance-terminate Lifecycle Action"]}",
|
||||
"EventPattern": {
|
||||
"detail-type": [
|
||||
"EC2 Instance-terminate Lifecycle Action"
|
||||
],
|
||||
"source": [
|
||||
"aws.autoscaling"
|
||||
]
|
||||
},
|
||||
"Targets": [
|
||||
{
|
||||
"Id": "1",
|
||||
|
@ -929,7 +936,14 @@
|
|||
"Type": "AWS::Events::Rule",
|
||||
"Properties": {
|
||||
"Name": "queueprocessor.example.com-RebalanceRecommendation",
|
||||
"EventPattern": "{"source": ["aws.ec2"],"detail-type": ["EC2 Instance Rebalance Recommendation"]}",
|
||||
"EventPattern": {
|
||||
"detail-type": [
|
||||
"EC2 Instance Rebalance Recommendation"
|
||||
],
|
||||
"source": [
|
||||
"aws.ec2"
|
||||
]
|
||||
},
|
||||
"Targets": [
|
||||
{
|
||||
"Id": "1",
|
||||
|
@ -942,7 +956,14 @@
|
|||
"Type": "AWS::Events::Rule",
|
||||
"Properties": {
|
||||
"Name": "queueprocessor.example.com-SpotInterruption",
|
||||
"EventPattern": "{"source": ["aws.ec2"],"detail-type": ["EC2 Spot Instance Interruption Warning"]}",
|
||||
"EventPattern": {
|
||||
"detail-type": [
|
||||
"EC2 Spot Instance Interruption Warning"
|
||||
],
|
||||
"source": [
|
||||
"aws.ec2"
|
||||
]
|
||||
},
|
||||
"Targets": [
|
||||
{
|
||||
"Id": "1",
|
||||
|
|
|
@ -17,12 +17,12 @@ limitations under the License.
|
|||
package awstasks
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/eventbridge"
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
"k8s.io/kops/upup/pkg/fi"
|
||||
"k8s.io/kops/upup/pkg/fi/cloudup/awsup"
|
||||
"k8s.io/kops/upup/pkg/fi/cloudup/cloudformation"
|
||||
|
@ -149,11 +149,22 @@ type cloudformationTarget struct {
|
|||
|
||||
type cloudformationEventBridgeRule struct {
|
||||
Name *string `json:"Name"`
|
||||
EventPattern *string `json:"EventPattern"`
|
||||
EventPattern map[string]interface{} `json:"EventPattern"`
|
||||
Targets []cloudformationTarget `json:"Targets"`
|
||||
}
|
||||
|
||||
func (_ *EventBridgeRule) RenderCloudformation(t *cloudformation.CloudformationTarget, a, e, changes *EventBridgeRule) error {
|
||||
// convert event pattern string into a json struct
|
||||
jsonString, err := fi.ResourceAsBytes(fi.NewStringResource(*e.EventPattern))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data := make(map[string]interface{})
|
||||
err = json.Unmarshal(jsonString, &data)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error parsing SQS PolicyDocument: %v", err)
|
||||
}
|
||||
|
||||
target := &cloudformationTarget{
|
||||
Id: s("1"),
|
||||
Arn: e.TargetArn,
|
||||
|
@ -161,7 +172,7 @@ func (_ *EventBridgeRule) RenderCloudformation(t *cloudformation.CloudformationT
|
|||
|
||||
cf := &cloudformationEventBridgeRule{
|
||||
Name: e.Name,
|
||||
EventPattern: e.EventPattern,
|
||||
EventPattern: data,
|
||||
Targets: []cloudformationTarget{*target},
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue