CloudFormation, Logs: Resolve LogGroup physical id and attributes (#6125)

* CloudFormation, Logs: Add physical_resource_id to LogGroup

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-loggroup.html#aws-resource-logs-loggroup-return-values

This brings CloudFormation's Ref behavior more in line with actual
AWS behavior. Previously, it returned an instance of a LogGroup model.

I didn't add a test case for this but I'm happy to do so if requested.

* Resolve LogGroup Fn::GetAtt

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-loggroup.html#aws-resource-logs-loggroup-return-values

* Add type annotations

* Add return type annotation

* Updating CloudFormation coverage
This commit is contained in:
Jordan Sanders 2023-03-28 07:17:56 -05:00 committed by GitHub
parent 93638de380
commit adb64bd97a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -272,8 +272,7 @@
- [x] create implemented - [x] create implemented
- [ ] update implemented - [ ] update implemented
- [ ] delete implemented - [ ] delete implemented
- [ ] Fn::GetAtt implemented - [x] Fn::GetAtt implemented
- [ ] Arn
- AWS::RDS::DBParameterGroup: - AWS::RDS::DBParameterGroup:
- [x] create implemented - [x] create implemented
- [ ] update implemented - [ ] update implemented

View File

@ -306,6 +306,23 @@ class LogGroup(CloudFormationModel):
resource_name, tags, **properties resource_name, tags, **properties
) )
@classmethod
def has_cfn_attr(cls, attr: str) -> bool:
return attr in [
"Arn",
]
def get_cfn_attribute(self, attribute_name: str) -> str:
from moto.cloudformation.exceptions import UnformattedGetAttTemplateException
if attribute_name == "Arn":
return self.arn
raise UnformattedGetAttTemplateException()
@property
def physical_resource_id(self) -> str:
return self.name
def create_log_stream(self, log_stream_name: str) -> None: def create_log_stream(self, log_stream_name: str) -> None:
if log_stream_name in self.streams: if log_stream_name in self.streams:
raise ResourceAlreadyExistsException() raise ResourceAlreadyExistsException()