Ask Your Question
4

How can the attribute PathPart be restricted as a read-only property in AWS CloudFormation?

asked 2023-05-20 17:00:52 +0000

devzero gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-05-20 17:07:01 +0000

qstack gravatar image

To restrict the attribute PathPart as a read-only property in AWS CloudFormation, you can use the UpdateReplacePolicy attribute in the resource definition. This attribute specifies what action to take if a modification is attempted on the attribute.

To set the attribute as read-only, you can set the UpdateReplacePolicy to Retain. This will prevent any modifications to the attribute during updates or replacements of the resource.

Here's an example:

"Resources": {
    "MyApiGatewayResource": {
        "Type": "AWS::ApiGateway::Resource",
        "Properties": {
            "RestApiId": {"Ref": "MyRestApi"},
            "ParentId": {"Fn::GetAtt": ["MyApiGatewayResourceParent", "Id"]},
            "PathPart": "myPathPart"
        },
        "UpdateReplacePolicy": "Retain"
    }
}

In this example, the attribute PathPart is set as "myPathPart" and the UpdateReplacePolicy is set as "Retain". This will make the attribute read-only during updates or resource replacements.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-20 17:00:52 +0000

Seen: 8 times

Last updated: May 20 '23