def test_calc_backend_config_with_role_arn(self): """Test that the correct role is used in backend config""" wrapper_config = WrapperConfig( backends=BackendsConfig( s3=S3BackendConfig( bucket=BUCKET, region=REGION, role_arn=ROLE_ARN ) ) ) actual_config = calc_backend_config( 'mock_directory/config/app1', {}, wrapper_config, BackendsConfig(s3=S3BackendConfig(bucket=BUCKET, region=REGION)) ) expected_config = [ '-reconfigure', '-backend-config=dynamodb_table=%s' % LOCK_TABLE, '-backend-config=encrypt=true', '-backend-config=key=terrawrap/config/app1.tfstate', '-backend-config=region=%s' % REGION, '-backend-config=bucket=%s' % BUCKET, '-backend-config=skip_region_validation=true', '-backend-config=skip_credentials_validation=true', '-backend-config=role_arn=%s' % ROLE_ARN ] self.assertEqual(expected_config, actual_config)
def test_calc_backend_config_wrapper_config(self): """Test that correct backend config is generated from the tf wrapper config""" wrapper_config = WrapperConfig(backends=BackendsConfig( s3=S3BackendConfig(bucket=BUCKET, region=REGION))) actual_config = calc_backend_config( 'mock_directory/config/app1', {}, wrapper_config, BackendsConfig(s3=S3BackendConfig(bucket=BUCKET, region=REGION))) expected_config = [ '-reconfigure', f'-backend-config=dynamodb_table={LOCK_TABLE}', '-backend-config=encrypt=true', '-backend-config=key=terrawrap/config/app1.tfstate', f'-backend-config=region={REGION}', f'-backend-config=bucket={BUCKET}', '-backend-config=skip_region_validation=true', '-backend-config=skip_credentials_validation=true' ] self.assertEqual(expected_config, actual_config)
def test_calc_backend_config(self): """Test that correct backend config is generated""" actual_config = calc_backend_config( 'mock_directory/config/app1', { 'region': REGION, 'account_short_name': 'test', }, WrapperConfig(), BackendsConfig(s3=S3BackendConfig(bucket=BUCKET, region=REGION))) expected_config = [ '-reconfigure', (f'-backend-config=dynamodb_table={LOCK_TABLE}'), '-backend-config=encrypt=true', '-backend-config=key=terrawrap/config/app1.tfstate', (f'-backend-config=region={REGION}'), (f'-backend-config=bucket={BUCKET}'), '-backend-config=skip_region_validation=true', '-backend-config=skip_credentials_validation=true' ] self.assertEqual(expected_config, actual_config)